What version of Remix are you using?
1.19
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Many libraries depend resp instanceof Response to return true; https://github.com/panva/oauth4webapi/blob/170f44e2f7c7da60feb8a654871c56fc0a741e6b/src/index.ts#L1513 is one of such a library. However, after Remix patches the global fetch instance, this no longer holds.
I've tested this with the following three scenarios:
- vanilla environment in node 20 (works)
- remix-run/web-fetch (works)
- remix-run/node (doesn't work)
{
// correct behavior
console.log((await fetch("http://example.com")) instanceof Response);
}
{
// also correct behavior
const i = await import("@remix-run/web-fetch");
console.log((await i.fetch("http://example.com")) instanceof i.Response);
}
{
// incorrect behavior; fails.
const j = await import("@remix-run/node");
console.log((await j.fetch("http://example.com")) instanceof j.Response);
}
The last one is important, as this is the version of globals that's installed via installGlobals.
Expected Behavior
(await fetch(...)) instanceof Response should return true for fetch and Response exposed by remix-run/node.
Actual Behavior
as the exposed types from remix-run/node is NodeResponse, the instanceof fails.
❓ Question
What I don't particularly understand is why we have the NodeRequest and NodeResponse. This is the reason why it's causing this type mismatch issue; these classes seem to be serving very little purpose. We're actually not instantiating these types at all, most of the (non-test) code is using ... as NodeResponse to coerce types. Can we just eliminate them, and expose @remix-run/web-fetch classes and types directly?
What version of Remix are you using?
1.19
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Many libraries depend
resp instanceof Responseto return true; https://github.com/panva/oauth4webapi/blob/170f44e2f7c7da60feb8a654871c56fc0a741e6b/src/index.ts#L1513 is one of such a library. However, after Remix patches the globalfetchinstance, this no longer holds.I've tested this with the following three scenarios:
The last one is important, as this is the version of globals that's installed via
installGlobals.Expected Behavior
(await fetch(...)) instanceof Responseshould returntruefor fetch and Response exposed byremix-run/node.Actual Behavior
as the exposed types from
remix-run/nodeisNodeResponse, theinstanceoffails.❓ Question
What I don't particularly understand is why we have the
NodeRequestandNodeResponse. This is the reason why it's causing this type mismatch issue; these classes seem to be serving very little purpose. We're actually not instantiating these types at all, most of the (non-test) code is using... as NodeResponseto coerce types. Can we just eliminate them, and expose@remix-run/web-fetchclasses and types directly?