Skip to content

fix(core): discovery url handling, error code review helper, and pack-n-play test timeouts - #9061

Open
bshaffer wants to merge 5 commits into
mainfrom
core-ci-fixes
Open

fix(core): discovery url handling, error code review helper, and pack-n-play test timeouts#9061
bshaffer wants to merge 5 commits into
mainfrom
core-ci-fixes

Conversation

@bshaffer

@bshaffer bshaffer commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Separated from #9058 to isolate Core library and pack-n-play CI fixes:

  • Resolves url.parse deprecations and Node 22+ URL discovery handling in nodejs-googleapis-common
  • Adds getErrorCode helper to gcp-metadata to properly unwrap AggregateError / cause hierarchies
  • Increases Windows CI timeout to 120s and adds --no-audit --no-fund flags in pack-n-play test fixtures

@bshaffer
bshaffer requested a review from a team as a code owner August 3, 2026 19:11

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates test timeouts and npm install flags in pack-n-play, replaces the deprecated url.parse with the modern URL API in nodejs-googleapis-common, and introduces a helper to extract error codes from nested errors in gcp-metadata. The review feedback highlights a potential issue in gcp-metadata where a wrapper error containing an AggregateError as its cause would fail to resolve properly and return 'UNKNOWN'. A recursive unwrapping function is suggested to handle this robustly.

Comment thread core/packages/gcp-metadata/src/index.ts Outdated
cwd: dir,
};
await execa('npm', ['install'], opts);
await execa('npm', ['install', '--no-audit', '--no-fund'], opts);

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.

I guess we should always do this for non-interactive npm installs, since we don't do anything with this info?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes i believe so, it's a small optimization

'Content-Type': 'application/json',
});
const disco = new Discovery({});
const makeEndpoint = await disco.discoverAPI(discoUrl);

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.

I think discoverAPI used to handle URLs without ports, so we should keep that part of the test (even if we need to pass the port to nock.)

Unless the test never passed?!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the reason we added the port is we switched to using new URL() API from the deprecated url.parse(), and the new URL() API requires a port.

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.

I'm not sure new URL() requires a port: https://nodejs.org/api/url.html#new-urlinput-base

If it did, I think we would need to update discoverAPI to infer a port based on the scheme (or modify the callers to make sure they pass a port)

I do think nock might need one. So it might be more correct to pass a port to nock and skip the port for discoverAPI.

});
it('should discover an API through second weird path', async () => {
const discoUrl = 'http://test.local';
const discoUrl = 'http://test.local:80';

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.

see above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as above, the reason we added the port is we switched to using new URL() API from the deprecated url.parse(), and the new URL() API requires a port.

Comment thread core/packages/gcp-metadata/src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants