-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: set Blobs context on the process #6284
Changes from 5 commits
0520a37
724569b
7ff4eeb
745f257
ddadb62
177b811
5aa70d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import { Worker } from 'worker_threads' | |
|
||
import lambdaLocal from 'lambda-local' | ||
|
||
import { BLOBS_CONTEXT_VARIABLE } from '../../../blobs/blobs.js' | ||
|
||
import detectNetlifyLambdaBuilder from './builders/netlify-lambda.js' | ||
import detectZisiBuilder, { parseFunctionForMetadata } from './builders/zisi.js' | ||
import { SECONDS_TO_MILLISECONDS } from './constants.js' | ||
|
@@ -104,6 +106,13 @@ export const invokeFunctionDirectly = async ({ context, event, func, timeout }) | |
const lambdaPath = func.buildData?.buildPath ?? func.mainFile | ||
const result = await lambdaLocal.execute({ | ||
clientContext: JSON.stringify(context), | ||
environment: { | ||
// We've set the Blobs context on the parent process, which means it will | ||
// be available to the Lambda. This would be inconsistent with production | ||
// where only V2 functions get the context injected. To fix it, unset the | ||
// context variable before invoking the function. | ||
[BLOBS_CONTEXT_VARIABLE]: undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the implementation of this, it seems like it mutates This leads to weird side-effects, like the env variable vanishing upon the first V1 Function execution. In this specific instance, it's probably alright because the framework child process was started earlier, and because V2 Functions don't rely on this env variable. But might be worth adding a comment. |
||
}, | ||
event, | ||
lambdaPath, | ||
timeoutMs: timeout * SECONDS_TO_MILLISECONDS, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally
@netlify/blobs
should export this.