Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class LocalLambdaStack extends Stack {
const functionName = `Npm${lambdaDir}`;

const lambdaPath = path.resolve(LAMBDA_FUNCTIONS_DIR, lambdaDir);
const packageLockPath = path.join(lambdaPath, 'package-lock.json');
const lockfilePath = path.join(lambdaPath, 'pnpm-lock.yaml');
const nodeModulesPath = path.join(lambdaPath, 'node_modules');

// `dir` is the package directory under `packages/`; `name` is the published npm name.
Expand Down Expand Up @@ -81,8 +81,8 @@ export class LocalLambdaStack extends Stack {

console.log(`[LocalLambdaStack] Install dependencies for ${functionName}`);

if (fs.existsSync(packageLockPath)) {
fs.rmSync(packageLockPath);
if (fs.existsSync(lockfilePath)) {
fs.rmSync(lockfilePath);
}

if (fs.existsSync(nodeModulesPath)) {
Expand All @@ -91,10 +91,20 @@ export class LocalLambdaStack extends Stack {

const packageJson = {
dependencies,
pnpm: {
overrides: dependencies,
},
};

fs.writeFileSync(path.join(lambdaPath, 'package.json'), JSON.stringify(packageJson, null, 2));
execFileSync('npm', ['install', '--install-links', '--prefix', lambdaPath], { stdio: 'inherit' });
execFileSync(
'pnpm',
['install', '--offline', '--prod', '--ignore-scripts', '--no-frozen-lockfile', '--config.node-linker=hoisted'],
{
cwd: lambdaPath,
stdio: 'inherit',
},
);
Comment on lines +100 to +107

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The pnpm install --offline command will fail in the CI environment because transitive registry dependencies are not pre-populated in the pnpm store.
Severity: CRITICAL

Suggested Fix

Add a CI step to pre-populate the pnpm store before the E2E tests run. This can be achieved by running pnpm fetch which will download all required packages, including transitive dependencies, into the store. This will allow the subsequent pnpm install --offline command to resolve all dependencies correctly.

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: dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts#L100-L107

Potential issue: The `pnpm install` command in `stack.ts` uses the `--offline` flag.
While direct dependencies are local, their transitive dependencies (e.g.,
`@sentry/conventions`, `@opentelemetry/api`) are from the package registry. The CI
environment does not pre-populate the pnpm store with these registry packages, as the
main project uses yarn and there is no preceding `pnpm fetch` step. Consequently, when
`pnpm install --offline` attempts to resolve these transitive dependencies, it will fail
because they are not available in the local store, causing all AWS serverless E2E tests
to fail.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nah, we run pnpm install in test:build first


if (!process.env.NODE_VERSION) {
throw new Error('[LocalLambdaStack] NODE_VERSION is not set');
Expand Down
Loading