Skip to content

Commit

Permalink
fix(lang-js): Set env vars before we iterate on beforeFuncs
Browse files Browse the repository at this point in the history
In a world where before funcs depend on beforeFuncs, we want the funcs to be able to see the results of each other so that they can work as expected

So if Func A writes to the environment, then we want that to be written before Func B runs otherwise Func B can't do it's thing
  • Loading branch information
stack72 committed Jul 26, 2024
1 parent 8d3e37c commit fa3c4b5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bin/lang-js/src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ export async function executeFunction(kind: FunctionKind, request: Request) {

for (const beforeFunction of request.before || []) {
await executor(ctx, beforeFunction, FunctionKind.Before, before);
}

// Set process environment variables, set from requestStorage
{
const requestStorageEnv = rawStorageRequest().env();
for (const key in requestStorageEnv) {
process.env[key] = requestStorageEnv[key];
// Set process environment variables, set from requestStorage
{
const requestStorageEnv = rawStorageRequest().env();
for (const key in requestStorageEnv) {
process.env[key] = requestStorageEnv[key];
}
}
}

Expand Down

0 comments on commit fa3c4b5

Please sign in to comment.