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

BUG: node-fetch/https.get doesn't work (Socket hang up) #7

Closed
jonathansampson opened this issue May 20, 2021 · 4 comments
Closed

BUG: node-fetch/https.get doesn't work (Socket hang up) #7

jonathansampson opened this issue May 20, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@jonathansampson
Copy link


name: Bug report
about: https://stackblitz.com/edit/node-zfkjjc?file=index.js
title: 'BUG: node-fetch/https.get doesn't work (Socket hang up)'
labels: 'http, socket, networking'
assignees: ''


Describe the bug
Unable to load remote data via node-fetch (or https module).

Link to the blitz that caused the error
https://stackblitz.com/edit/node-zfkjjc?file=index.js

Expected behavior
A clear and concise description of what you expected to happen.

Version of webcontainer
Hash: 7286dbe8d47d3473cde7be488b7d048fb59b05f2

Desktop (please complete the following information):
Browser name = Brave
Full version = 90.0.4430.212
Major version = 90
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
performance.memory = {
totalJSHeapSize: 56890553,
usedJSHeapSize: 50431077,
jsHeapSizeLimit: 4294705152
}

@KwintenP
Copy link
Contributor

This is supposed to work. Bug confirmed.

Thanks for reporting 🙏

@KwintenP KwintenP added the bug Something isn't working label May 20, 2021
@janpio
Copy link

janpio commented May 20, 2021

This is probably caused by the browser rejecting the request because of CORS reasons. From the linked Blitz above, https://stackblitz.com/edit/node-zfkjjc?file=index.js, I get this in my console before the hangup message comes:

Access to fetch at 'https://sampson.codes/' from origin 'https://node-zfkjjc.jw.staticblitz.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

image

Something very similar happens in our Node ORM Prisma, which needs to download a binary from a server to work: prisma/prisma#7185

@janpio
Copy link

janpio commented May 20, 2021

You can unblock yourself by installing for example this Chrome extension: https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en

@KwintenP
Copy link
Contributor

Like @janpio said, this issue happens cause it's not possible to call the url from the browser's env, which is where WebContainer is running.

See an example here: https://stackblitz.com/edit/typescript-ive2dd.

You need to make sure this call works, and then the v2 project should also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants