-
-
Notifications
You must be signed in to change notification settings - Fork 531
Upgrading to 0.10.0 results in Failed to execute 'fetch' on 'Window' #1715
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
Comments
Edit: sorry; replied to wrong issue. |
Could you provide a reproduction of this and give more information about what environment you’re fetching in (browser? node? deno?)? The tests are currently passing, and I’m not able to replicate it myself. I believe you’re having the issue, but not sure what hole our test suite has that needs to be filled. |
Hi, I don't have a repro currently but can look to put something together. This is an NX monorepo with apps in a browser environment. The only piece of middleware I have is: {
onRequest: (req) => {
// add authentication
req.headers.set('Authorization', `Bearer ${accessToken}`);
// incorrectly sets headers for GET requests
// https://github.com/drwpow/openapi-typescript/issues/1410
if (req.method === 'GET' || req.method === 'DELETE') {
req.headers.delete('Content-Type');
}
return req;
},
} which after the update I have altered to this inline with the docs. {
onRequest: ({ request }) => {
// add authentication
request.headers.set('Authorization', `Bearer ${accessToken}`);
// incorrectly sets headers for GET requests
// https://github.com/drwpow/openapi-typescript/issues/1410
if (request.method === 'GET' || request.method === 'DELETE') {
request.headers.delete('Content-Type');
}
return request;
},
} The rest is all pretty standard stuff: const client = createClient<paths>({
baseUrl,
});
await client.POST('/api/organisations/', { body: { name }, }); It never invokes a request and fails in the openapi-fetch library. |
I've since put a breakpoint in the openapi-fetch.js implementation of If I supplement the |
Same issue here. The weird part is that (at least in my case) it only happens when executing E2E tests with playwright and happy-dom. In the console trace of the now failing tests I find the same error:
|
I think the reason for the error is that an instance of |
Hi. I ran into this while doing some testing of this lib. I have a small repo that reproduces the error: It is not really refined and a bit hacked toghether with conda environments etc, so not the perfect repo to look at maybe, but I though I would leave it here anyway. If you manage to run the backend (open-api/be/) and the frontend (open-api/fe/) it should reproduce the error in the console if you press the send button in the UI. |
I'm also facing this issue |
Thank you all! Will push a fix to this later today. This also gives me enough info to see what needs to be added to the test suites to prevent this from happening again. |
Ah that’s it exactly. This change was to improve support for third-party custom fetchers, such as #1691, but it’s a flawed implementation and this currently doesn’t match the fetch spec. Will improve this handling so that it both matches the official fetch spec, and is also friendly to third-party fetch clients that aren’t technically spec-compliant but are close. |
Also digging through other instances of this error, this seems to be an issue specific to Chrome/Chromium which made it difficult to catch 😅 (technically our tests run in Node.js, not Chromium). Safari has a different-but-related error, and in Firefox this Just Works™. Anyway, wanted to dig further into the root issue before I understood the best fix to take (and I believe actual headless Playwright tests are the best thing to add here, rather than try and hack together Chrome and Safari tests in Node.js which are moving targets to say the least) |
Description
Upgraded to 0.10.0 (and 7.0.0 of openapi-typescript). Perform
.POST(..)
method and receive:Reproduction
As above, previously working POST request on 0.9.0, upgrade to latest 0.10.0. Execute same POST request
Expected result
To not throw.
Checklist
The text was updated successfully, but these errors were encountered: