-
Notifications
You must be signed in to change notification settings - Fork 41
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
Synchronous XHR processing not implemented #19
Comments
@retorquere I looked into doing it, and everything I could find is really ugly. node's http libraries don't support synchronous requests, so I'd have to do a synchronous spawn and do all the processing in a child. This is a lot of work for a feature that most Web platform folks want deprecated. On the bright side, there seem to be a few libraries doing synchronous HTTP, and that wasn't the case last time I looked into implementing synchronous XHR. |
I've found some, thanks. For my case, I don't see a way around synchronous.
|
@retorquere Do you happen to have any recommendations? I'm working on a CLI app, and asynchronous behavior is breaking core functionality. |
xmlhttprequest package supports synchronous yet |
Ran into a painful debugging scenario before I realised that this module doesn't support sync XMLHttpRequest's. I might open a PR to at least throw an error if someone attempts to use this, to make debugging easier. |
I created to-sync today it utilize web workers instead of spawning sync processes and data is transfered synchronous over Therefore it's also more compatible with other enviorments like Deno, Bun, and also Web Workers. it's as simple as just doing: import { createWorker } from 'to-sync'
const toSync = createWorker()
const fetchSync = toSync(async function (...args) {
const res = await fetch(...args)
const ab = await res.arrayBuffer()
return new Uint8Array(ab)
})
const uint8 = fetchSync(url)
const text = new TextDecoder().decode(uint8)
const json = JSON.parse(text)
const blob = new Blob([uint8]) check it out... it's very easy to use. |
I'm trying to d a synchronous POST, but I'm getting "Synchronous XHR processing not implemented". code:
The text was updated successfully, but these errors were encountered: