chore(aws-serverless): Don't build layer in build:dev command#19586
chore(aws-serverless): Don't build layer in build:dev command#19586
build:dev command#19586Conversation
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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)
| "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", |
There was a problem hiding this comment.
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)
| }, | ||
| "scripts": { | ||
| "build": "run-p build:transpile build:types", | ||
| "build": "run-p build:transpile build:layer build:types", |
There was a problem hiding this comment.
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.
size-limit report 📦
|


Similar to browser bundles, the layer does not need to be built during
devbuilds.Closes #19587 (added automatically)