Skip to content

Commit

Permalink
DOCS-1870: Remove outdated Cloudflare Workers information from JavaSc…
Browse files Browse the repository at this point in the history
…ript driver docs (#579)

* release 5.0.0

* changelog

* update readme

* update readme

* chore: added beta tag to release

* DOCS-1870: undo change to publish.sh

Co-authored-by: SZinkevych <s.zinkevych@gmail.com>
Co-authored-by: Stanislav Parkhomenko <stanislav.parkhomenko@gmail.com>
  • Loading branch information
3 people committed Dec 8, 2021
1 parent 6ea18e9 commit 6e386ec
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,33 +427,6 @@ async function main() {
main().catch(console.error)
```

## Known issues

### Using with Cloudflare Workers

Cloudflare Workers have neither XMLHttpRequest nor fetch in the global scope.
Therefore, the `cross-fetch` package is unable to inject its own `fetch()` function, and throws an error.
The `fetch()` function is injected via a closure, so the workaround would be to pass
the fetch objects when initiating the FaunaDB client config. Cloudflare Workers also
doesn't support the use of an AbortController, which terminates requests as well as streams.
Here is a workaround:

```javascript
const c = new faunadb.Client({
secret: 'your secret',
fetch: (url, params) => {
const signal = params.signal
delete params.signal
const abortPromise = new Promise(resolve => {
if (signal) {
signal.onabort = resolve
}
})
return Promise.race([abortPromise, fetch(url, params)])
},
})
```

## Client Development

Run `yarn` to install dependencies.
Expand Down

0 comments on commit 6e386ec

Please sign in to comment.