Skip to content

fix: improve node-fetch compatibility in error cases MONGOSH-2443 #224

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

addaleax
Copy link
Contributor

@addaleax addaleax commented Aug 7, 2025

node-fetch currently does not return a body that is a web/standard ReadableStream, which is what openid-client expects. Since it only makes use of this in error cases, no additional cases are broken, but the error message is highly unhelpful in these cases.

Unfortunately, it is not trivial to resolve this without fully wrapping the node-fetch, so this provides a limited compatibility layer rather than a full-featured one. (Note – I'm opening the PR with this approach but I'd be up for changing this if somebody feels strongly that we should put in the effort to provide a full layer around Response. We can't "just" replace .body only because node-fetch's .text() and .json() methods expect it to be a Node.js stream.)

`node-fetch` currently does not return a body that is a web/standard
`ReadableStream`, which is what openid-client expects. Since it only
makes use of this in error cases, no additional cases are broken,
but the error message is highly unhelpful in these cases.

Unfortunately, it is not trivial to resolve this without fully wrapping
the `node-fetch`, so this provides a limited compatibility layer rather
than a full-featured one.
@github-actions github-actions bot added the fix label Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant