Skip to content

Commit d522cc3

Browse files
committed
Address code review feedback
Fix setEnvVars to throw proper ServiceError with COMMAND_EXECUTION_ERROR code and CommandErrorContext details instead of generic Error. Expand deadlock warning to cover both withSession and executeInSession.
1 parent 0c2d8e9 commit d522cc3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/sandbox-container/src/services/session-manager.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ export class SessionManager {
285285
* The lock is held for the entire callback duration, preventing
286286
* other operations from interleaving.
287287
*
288-
* WARNING: Do not call withSession recursively on the same session - it will deadlock.
288+
* WARNING: Do not call withSession or executeInSession recursively on the same
289+
* session - it will deadlock. Cross-session calls are safe.
289290
*
290291
* @param sessionId - The session identifier
291292
* @param fn - Callback that receives an exec function for running commands
@@ -709,9 +710,15 @@ export class SessionManager {
709710
const result = await exec(exportCommand);
710711

711712
if (result.exitCode !== 0) {
712-
throw new Error(
713-
`Failed to set environment variable '${key}': ${result.stderr}`
714-
);
713+
throw {
714+
code: ErrorCode.COMMAND_EXECUTION_ERROR,
715+
message: `Failed to set environment variable '${key}': ${result.stderr}`,
716+
details: {
717+
command: exportCommand,
718+
exitCode: result.exitCode,
719+
stderr: result.stderr
720+
} satisfies CommandErrorContext
721+
};
715722
}
716723
}
717724
});

0 commit comments

Comments
 (0)