Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/.config/esbuild.cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ const config = {
},

plugins: [
unicodeTransformPlugin(),
// Environment variable replacement must run AFTER unicode transform.
envVarReplacementPlugin(inlinedEnvVars),
unicodeTransformPlugin(),
{
name: 'resolve-socket-lib-internals',
setup(build) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dev:npx": "cross-env SOCKET_CLI_MODE=npx node --experimental-strip-types src/cli-dispatch.mts",
"e2e-tests": "dotenvx -q run -f .env.test -- vitest run --config vitest.e2e.config.mts",
"e2e:js": "node scripts/e2e.mjs --js",
"e2e:sea": "node scripts/e2e.mjs --sea",
"e2e:sea": "node scripts/e2e.mjs --sea",
"e2e:all": "node scripts/e2e.mjs --all",
"test": "run-s check test:*",
"test:prepare": "dotenvx -q run -f .env.test -- pnpm build && del-cli 'test/**/node_modules'",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function main() {

if (!watchResult || watchResult.code !== 0) {
process.exitCode = watchResult?.code ?? 1
throw new Error(`Watch mode failed with exit code ${watchResult?.code}`)
throw new Error(`Watch mode failed with exit code ${watchResult?.code ?? 1}`)
}
return
}
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/scripts/download-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ async function downloadAssets(assetNames, parallel = true) {
)

const failed = settled.filter(
r => r.status === 'fulfilled' && !r.value.ok,
r => r.status === 'rejected' || (r.status === 'fulfilled' && !r.value.ok),
)
if (failed.length > 0) {
logger.error(`\n${failed.length} asset(s) failed:`)
for (const r of failed) {
logger.error(` - ${r.value.name}`)
logger.error(
` - ${r.status === 'rejected' ? r.reason?.message ?? r.reason : r.value.name}`,
)
}
process.exitCode = 1
}
Expand Down
1 change: 1 addition & 0 deletions packages/cli/scripts/esbuild-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,6 @@ export async function runBuild(config, description = 'Build') {
logger.error(`Build failed: ${description || 'Unknown'}`)
logger.error(e)
process.exitCode = 1
throw e
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rethrown error causes unhandled rejection in standalone callers

Medium Severity

Adding throw e in runBuild's catch block enables Promise.allSettled detection in esbuild.build.mjs, which properly handles rejections. However, esbuild.cli.mjs (line 203) and esbuild.index.mjs (line 23) call runBuild() without a .catch() handler. On build failure, this now produces an unhandled promise rejection in those standalone scripts, resulting in duplicate error output and a noisy Node.js crash trace. The esbuild.cli.mjs script is specifically spawned as a child process during watch mode.

Additional Locations (1)
Fix in Cursor Fix in Web

}
}