Visitar URL original
test(google-auth-library): remove --assert-deep-equal-shim and fix Headers by danieljbruce · Pull Request #9559 · googleapis/google-cloud-node · GitHub
Skip to content

test(google-auth-library): remove --assert-deep-equal-shim and fix Headers - #9559

Merged
quirogas merged 4 commits into
googleapis:mainfrom
danieljbruce:fix/remove-assert-deep-equal-shim
Oct 9, 2026
Merged

quirogas merged 4 commits into
googleapis:mainfrom
danieljbruce:fix/remove-assert-deep-equal-shim

Conversation

@danieljbruce

Copy link
Copy Markdown
Contributor

Description

Removes the --assert-deep-equal-shim (assert.deepEqual) monkey patch from bin/proxyquire-bun-shim.cjs and bin/run-test.cjs, and fixes the Headers object spread in core/packages/google-auth-library-nodejs/test/test.googleauth.ts (b/570683628).

In core/packages/google-auth-library-nodejs/test/test.googleauth.ts (line 343), MyAuthClient.getRequestHeaders() returned Gaxios.mergeHeaders({...customRequestHeaders}) where customRequestHeaders is a Fetch Headers instance (new Headers({'my-unique': 'header'})). Because Fetch Headers stores header entries in internal slots rather than own enumerable properties, {...customRequestHeaders} evaluates to {} and Gaxios.mergeHeaders({...customRequestHeaders}) returns an empty Headers instance. In Node.js (undici), assert.deepEqual(new Headers(), new Headers({'my-unique': 'header'})) spuriously passed because neither Headers instance has own enumerable properties, whereas in Bun assert.deepEqual inspects Headers entries and caught the bug.

Impact

  • core/packages/google-auth-library-nodejs: test/test.googleauth.ts now passes customRequestHeaders directly to Gaxios.mergeHeaders(customRequestHeaders) so the custom header is preserved as intended by the test.
  • bin/proxyquire-bun-shim.cjs & bin/run-test.cjs: Removes --assert-deep-equal-shim (BUN_ASSERT_DEEP_EQUAL_SHIM / BUN_ENABLE_ASSERT_DEEP_EQUAL_SHIM) and the assert.deepEqual monkey patch.

Changes

  • core/packages/google-auth-library-nodejs/test/test.googleauth.ts: Pass customRequestHeaders (instead of {...customRequestHeaders}) to Gaxios.mergeHeaders(...) in should accept and use an AuthClient.
  • core/packages/google-auth-library-nodejs/package.json, bin/run-test.cjs, bin/proxyquire-bun-shim.cjs: Remove --assert-deep-equal-shim and its implementation.

Testing

  • Executed pnpm --dir core/packages/google-auth-library-nodejs test under both Node.js and Bun (JS_RUNTIME=bun).
  • Verified repeated unit test runs pass with 0 failures across both runtimes.

Alternatives

  • Keeping the assert.deepEqual monkey patch in bin/proxyquire-bun-shim.cjs (which ignored empty Headers comparisons) was rejected because it masked a real bug in the test where spreading a Headers instance dropped all headers (b/570091189).

@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 removes the assert.deepEqual shim logic and its associated configuration flags (--assert-deep-equal-shim and BUN_ENABLE_ASSERT_DEEP_EQUAL_SHIM) across the proxyquire Bun shim and test runner. Additionally, it simplifies a header merging call in test.googleauth.ts by passing customRequestHeaders directly instead of spreading it. There are no review comments to address, so I have no further feedback to provide.

@danieljbruce

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 removes the assert.deepEqual shim (--assert-deep-equal-shim) from the test runner and proxyquire shim configurations. Additionally, in the google-auth-library-nodejs tests, the getRequestHeaders method has been updated to explicitly pass a Headers instance to Gaxios.mergeHeaders, alongside some minor formatting adjustments. No review comments were provided, so there is no additional feedback to address.


async getRequestHeaders() {
return Gaxios.mergeHeaders({...customRequestHeaders});
return Gaxios.mergeHeaders(new Headers(), customRequestHeaders);

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.

Add a comment here explaining why new headers are needed.

@danieljbruce

Copy link
Copy Markdown
Contributor Author

We just need to solve the merge conflicts. We should also modify the conventional commit since only tests are changed here.

@quirogas quirogas 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.

PR looks good, interesting how Bun vs Node do deepEquals checks 🤯

@quirogas quirogas changed the title fix(google-auth-library): remove --assert-deep-equal-shim and fix Headers test(google-auth-library): remove --assert-deep-equal-shim and fix Headers Oct 8, 2026
@quirogas
quirogas marked this pull request as ready for review October 8, 2026 18:52
@quirogas
quirogas requested review from a team as code owners October 8, 2026 18:52
@github-actions
github-actions Bot requested a review from shivanee-p October 8, 2026 18:52
@quirogas quirogas assigned quirogas and unassigned danieljbruce Oct 8, 2026
@quirogas
quirogas enabled auto-merge (squash) October 9, 2026 00:00
@quirogas
quirogas merged commit 09acd33 into googleapis:main Oct 9, 2026
46 checks passed
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