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

node js compatibility #28

Closed
b1f6c1c4 opened this issue Jan 19, 2020 · 6 comments
Closed

node js compatibility #28

b1f6c1c4 opened this issue Jan 19, 2020 · 6 comments

Comments

@b1f6c1c4
Copy link

This paragraph causes the following error in nodejs:
Error: XMLHttpRequest is not defined (503)

I recommend using axios for this.

@or-else
Copy link
Contributor

or-else commented Jan 19, 2020

XMLHttpRequest is used only in long polling. Long polling is a fallback mechanism when websockets are not available. Given that you fully control your node environment, you can always include a websocket provider and consequently long polling won't ever be needed. Have you provided a websocket implementation as suggested?
https://github.com/tinode/tinode-js/blob/master/README.md#node-js-compatibility

@or-else
Copy link
Contributor

or-else commented Jan 19, 2020

Actually XMLHttpRequest is also used in file uploads, so I suppose it needs to be polyfilled too.
And URL.createObjectUrl() needs to be polyfilled. I'll make the changes in the SDK.

@or-else or-else added bug and removed question labels Jan 19, 2020
@or-else
Copy link
Contributor

or-else commented Jan 19, 2020

OK, I've updated the SDK to allow polyfilling of XMLHttpRequest too and added instructions how to do it.

The URL.createObjectURL is still not polyfilled and I don't have time to work on it right now. We do not use this code under Node. You are welcome to send a pull request.

@b1f6c1c4
Copy link
Author

Related: nodejs/node#16167

@or-else
Copy link
Contributor

or-else commented Jan 20, 2020

A full replacement is great, but a workaround would be sufficient too. Maybe an alternative way of downloading when createObjectURL is not available. Or maybe have createObjectURL return a data URL https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

@or-else
Copy link
Contributor

or-else commented Apr 12, 2023

The original issue with XMLHttpRequest has been resolved. The createObjectURL was added in Node v16.7.0.

Let's close this issue as it is no longer clear what's exactly missing. Please file a new issue if something is still broken when running in Node environment.

@or-else or-else closed this as completed Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants