sandpack icon indicating copy to clipboard operation
sandpack copied to clipboard

sandpack cannot connect to the runtime or your network is having some issues

Open SandStorm44 opened this issue 2 years ago • 9 comments

Couldn't connect to server

This means sandpack cannot connect to the runtime or your network is having some issues. Please check the network tab in your browser and try again. If the problem persists, report it via email or submit an issue on GitHub.

ENV: ERROR: TIME_OUT

SandStorm44 avatar Jul 14 '23 16:07 SandStorm44

I see this issue consistently when doing a production build with Astro.

Works absolutely fine in dev.

chopfitzroy avatar Jul 20 '23 10:07 chopfitzroy

I'm having this error as well for the sandpack in an online course (ui.dev). Any clue?

ical10 avatar Jul 22 '23 14:07 ical10

@chopfitzroy how do we run sandpack in dev mode?

eppisai avatar Jul 26 '23 05:07 eppisai

Sorry should have been more clear, running the Astro development server works, building for production with Astro causes the above issue.

I did find that updating the Astro directive on the component from client:load to client:only resolved the issue but it's not an ideal fix. In my case the issue appears to be Astro SSR.

chopfitzroy avatar Jul 26 '23 09:07 chopfitzroy

always timeout on my phone

https://blocksuite.affine.pro/getting-started.html

Screenshot_20231025-082040.jpg

jerrywu001 avatar Oct 25 '23 00:10 jerrywu001

Did anyone found a solution?

theashishmaurya avatar Feb 24 '24 15:02 theashishmaurya

Check the vite config, disabling "Cross-Origin-Embedder-Policy": "require-corp" fixed the issue.

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  optimizeDeps: {
    exclude: ["@ffmpeg/ffmpeg", "@ffmpeg/util"],
  },
  server: {
    // headers: {
    //   "Cross-Origin-Opener-Policy": "same-origin",
    //   "Cross-Origin-Embedder-Policy": "require-corp",
    // },
  },
});

theashishmaurya avatar Feb 24 '24 15:02 theashishmaurya

@theashishmaurya solution is correct, however if the web page still requires SharedArrayBuffer(e.g you are running something like WebContainers.io or WASI in the same page/URL), those HTTP headers are required, not sure if there are any valid options that can help co-host sandpack and webcontainers or some WASI in the same web page.

noteverseio avatar Apr 20 '24 03:04 noteverseio