Skip to content

chore(aws-serverless): Don't build layer in build:dev command#19586

Open
s1gr1d wants to merge 1 commit intodevelopfrom
sig/aws-dev-build
Open

chore(aws-serverless): Don't build layer in build:dev command#19586
s1gr1d wants to merge 1 commit intodevelopfrom
sig/aws-dev-build

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Mar 2, 2026

Similar to browser bundles, the layer does not need to be built during dev builds.

Closes #19587 (added automatically)

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

},
"scripts": {
"build": "run-p build:transpile build:types",
"build": "run-p build:transpile build:layer build:types",
Copy link

Choose a reason for hiding this comment

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

Race condition: layer build depends on transpile output

High Severity

The build command now runs build:transpile and build:layer in parallel via run-p, but build:layer has an implicit dependency on build:transpile's output. The buildLambdaLayer.ts script runs yarn install on a file: reference to the local package, which copies files from build/npm/ (produced by build:transpile), and pruneNodeModules traces entrypoints inside build/npm/cjs and build/npm/esm. Previously these ran sequentially (rollup ... && yarn build:layer), which guaranteed correctness. Running them in parallel may cause the layer build to fail or produce an incomplete layer.

Additional Locations (1)

Fix in Cursor Fix in Web

"build:layer": "rimraf build/aws && rollup -c rollup.lambda-extension.config.mjs && yarn ts-node scripts/buildLambdaLayer.ts",
"build:dev": "run-p build:transpile build:types",
"build:transpile": "rollup -c rollup.npm.config.mjs && yarn build:layer",
"build:transpile": "rollup -c rollup.npm.config.mjs",
Copy link

Choose a reason for hiding this comment

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

Stale nx outputs config for build:transpile target

Medium Severity

The nx target config for build:transpile still lists {projectRoot}/build/aws as an output, but build:transpile no longer produces the build/aws directory — that's now produced by the separate build:layer command. This causes incorrect nx caching: cache hits for build:transpile would restore (or fail to restore) build/aws, and build:layer has no nx target definition for its outputs.

Additional Locations (1)

Fix in Cursor Fix in Web

},
"scripts": {
"build": "run-p build:transpile build:types",
"build": "run-p build:transpile build:layer build:types",
Copy link

Choose a reason for hiding this comment

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

Bug: The build script runs build:transpile and build:layer in parallel, creating a race condition. build:layer may fail because it depends on files that build:transpile has not yet created.
Severity: CRITICAL

Suggested Fix

Re-introduce sequential execution to ensure dependencies are met. Either use run-s for sequential execution or reorder the commands to run build:transpile first, for example: "run-s build:transpile && run-p build:layer build:types". Alternatively, add an explicit dependency configuration in nx.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/aws-serverless/package.json#L82

Potential issue: The `build` script was changed to run `build:transpile` and
`build:layer` in parallel using `run-p`. The `build:layer` script depends on artifacts
created by `build:transpile`. Specifically, `build:layer` runs `yarn install` on a local
package using the `file:` protocol, which requires the transpiled output files (e.g.,
`build/npm/cjs/index.js`) to already exist. Because the tasks now run in parallel,
`build:layer` can start before `build:transpile` has finished, leading to a race
condition that causes the build to fail when the required files are not yet available.
This will cause intermittent failures in the production release build.

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.63 kB - -
@sentry/browser - with treeshaking flags 24.13 kB - -
@sentry/browser (incl. Tracing) 42.43 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.09 kB - -
@sentry/browser (incl. Tracing, Replay) 81.25 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.87 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.95 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.21 kB - -
@sentry/browser (incl. Feedback) 42.44 kB - -
@sentry/browser (incl. sendFeedback) 30.29 kB - -
@sentry/browser (incl. FeedbackAsync) 35.35 kB - -
@sentry/browser (incl. Metrics) 26.8 kB - -
@sentry/browser (incl. Logs) 26.94 kB - -
@sentry/browser (incl. Metrics & Logs) 27.61 kB - -
@sentry/react 27.38 kB - -
@sentry/react (incl. Tracing) 44.77 kB - -
@sentry/vue 30.08 kB - -
@sentry/vue (incl. Tracing) 44.3 kB - -
@sentry/svelte 25.66 kB - -
CDN Bundle 28.17 kB - -
CDN Bundle (incl. Tracing) 43.26 kB - -
CDN Bundle (incl. Logs, Metrics) 29.01 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.1 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.09 kB - -
CDN Bundle (incl. Tracing, Replay) 80.14 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.65 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.53 kB - -
CDN Bundle - uncompressed 82.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 128.07 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.19 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.85 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.95 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.67 kB - -
@sentry/nextjs (client) 47.18 kB - -
@sentry/sveltekit (client) 42.89 kB - -
@sentry/node-core 52.24 kB +0.02% +9 B 🔺
@sentry/node 174.69 kB +0.01% +4 B 🔺
@sentry/node - without tracing 97.39 kB +0.02% +10 B 🔺
@sentry/aws-serverless 113.19 kB +0.01% +8 B 🔺

View base workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(aws-serverless): Don't build layer in build:dev command

1 participant