Skip to content
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

Disable metadata service detection in the emulator. #6860

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inject an environment variable in the node functions emulator to tell the google-gax SDK not to look for the metadata service. (#6860)
2 changes: 1 addition & 1 deletion src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
createHubServer(): express.Application {
// TODO(samstern): Should not need this here but some tests are directly calling this method
// because FunctionsEmulator.start() used to not be test safe.
this.workQueue.start();

Check warning on line 274 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

const hub = express();

Expand Down Expand Up @@ -313,15 +313,15 @@
const multicastHandler: express.RequestHandler = (req: express.Request, res) => {
const projectId = req.params.project_id;
const rawBody = (req as RequestWithRawBody).rawBody;
const event = JSON.parse(rawBody.toString());

Check warning on line 316 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
let triggerKey: string;
if (req.headers["content-type"]?.includes("cloudevent")) {
triggerKey = `${this.args.projectId}:${event.type}`;

Check warning on line 319 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 319 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .type on an `any` value
} else {
triggerKey = `${this.args.projectId}:${event.eventType}`;

Check warning on line 321 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 321 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .eventType on an `any` value
}
if (event.data.bucket) {

Check warning on line 323 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .data on an `any` value
triggerKey += `:${event.data.bucket}`;

Check warning on line 324 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

Check warning on line 324 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .data on an `any` value
}
const triggers = this.multicastTriggers[triggerKey] || [];

Expand Down Expand Up @@ -366,7 +366,7 @@
return hub;
}

async sendRequest(trigger: EmulatedTriggerDefinition, body?: any) {

Check warning on line 369 in src/emulator/functionsEmulator.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const record = this.getTriggerRecordByKey(this.getTriggerKey(trigger));
const pool = this.workerPools[record.backend.codebase];
if (!pool.readyForWork(trigger.id)) {
Expand Down Expand Up @@ -1349,6 +1349,7 @@
cwd: backend.functionsDir,
env: {
node: backend.bin,
METADATA_SERVER_DETECTION: "none",
...process.env,
...envs,
PORT: socketPath,
Expand Down Expand Up @@ -1451,7 +1452,6 @@
/**
* Gets the address of a running emulator, either from explicit args or by
* consulting the emulator registry.
*
* @param emulator
*/
private getEmulatorInfo(emulator: Emulators): EmulatorInfo | undefined {
Expand Down
Loading