Skip to content
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

Option to use fetch instead of XMLHttpRequest for polling #716

Open
matthiasgeihs opened this issue Dec 11, 2023 · 2 comments
Open

Option to use fetch instead of XMLHttpRequest for polling #716

matthiasgeihs opened this issue Dec 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@matthiasgeihs
Copy link

Is your feature request related to a problem? Please describe.
Some environments don't support XMLHttpRequest, but support fetch.
(e.g., MetaMask Snaps)

Describe the solution you'd like
It would be great if there was an option for using fetch instead XMLHttpRequest.

Describe alternatives you've considered
There seems to be a way to solve this problem via a postinstall patch (as described in the article linked above), but native support would be favored.

@matthiasgeihs matthiasgeihs added the enhancement New feature or request label Dec 11, 2023
@zhengcling
Copy link

I also have this need currently.

@darrachequesne
Copy link
Member

We could indeed let the user overrides the list of available low-level transports. Not sure how it could work with tree-shaking though.

darrachequesne added a commit that referenced this issue Apr 23, 2024
Usage:

```js
import { Socket, transports, Fetch } from "engine.io-client";

transports.polling = Fetch;

const socket = new Socket("https://example.com");
```

Note: tree-shaking unused transports is not currently supported and
will be added later.

Related:

- socketio/socket.io#4980
- #716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants