-
Notifications
You must be signed in to change notification settings - Fork 73
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
Cloudflare Workers and global fetch??? #548
Comments
Internal ticket number is OSS-958 |
FYI The known issues section of the README that the OP referenced has apparently been removed in this commit by @parkhomenko : It's not clear if anything else other than the doc removal has changed. |
AbortController and AbortSignal are both supported now. It seems this is why the docs were removed and I believe this issue can be closed now. https://community.cloudflare.com/t/2021-9-24-workers-runtime-release-notes/308821 Only for reference, no longer neededThis is how the workaround would have needed to be typed to work with TypeScript. But the workaround itself is no longer necessary now, so don't copy this into any new projects. You don't need to specify new faunadb.Client({
// ...
fetch: (
url: RequestInfo,
params?: RequestInit | undefined
): Promise<Response> => {
let signal: RequestInit["signal"];
if (params) {
signal = params.signal;
delete params.signal;
}
const abortPromise = new Promise<Response>((resolve) => {
if (signal) {
// @ts-ignore
signal.onabort = resolve;
}
});
return Promise.race([abortPromise, patchedFetch(url, params)]);
},
}) |
I have been trying to figure out a way to make this...
https://github.com/fauna/faunadb-js#known-issues
Work with Typescript. But I'm confused.
Cloudlfare Workers do have a native fetch so I'm confused as to why the workaround is needed.
I can't find anything about them supporting AbortController.... but maybe we can set a timeout and skill the Fauna Request or the stream. Although if it's a stream would you not kill that manually???
Can you help explain how Fauna uses cross-fetch more?
Maybe there is a way around this. Cloudflare Workers did just release Workers Unbound with 30 seconds of "alive" time.. not sure what you realy call that.
Anyway I would really love to get this working with TS support but I am at a standstill at the moment.
The text was updated successfully, but these errors were encountered: