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

TypeError: Cannot perform Construct on a detached ArrayBuffer on worker-chat-demo #171

Closed
segator opened this issue Feb 6, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@segator
Copy link

segator commented Feb 6, 2022

Hi everyone first time using cloudflare workers and I wanted to start on a local environment where I can debug.
I got an exmaple of cloudflare to evaluate WSS but it crashes, Do i'm doing something wrong or miniflare have a bug?

git clone https://github.com/cloudflare/workers-chat-demo
cd workers-chat-demo
miniflare

if you then open http://localhost:8787/ and refresh page or F5 you got this error.

TypeError: Cannot perform Construct on a detached ArrayBuffer
    at new Uint8Array (<anonymous>)
    at extractBody (/usr/local/lib/node_modules/miniflare/node_modules/undici/lib/fetch/body.js:73:14)
    at new Response (/usr/local/lib/node_modules/miniflare/node_modules/undici/lib/fetch/response.js:166:44)
    at new Response (/usr/local/lib/node_modules/miniflare/node_modules/@miniflare/core/src/standards/http.ts:556:13)
    at xxxxx/workers-chat-demo-master/src/chat.mjs:104:16
    at handleErrors (xxxxxx/workers-chat-demo-master/src/chat.mjs:69:18)
    at Object.fetch (xxxxx/workers-chat-demo-master/src/chat.mjs:96:18)
    at /usr/local/lib/node_modules/miniflare/node_modules/@miniflare/core/src/standards/event.ts:331:19
    at /usr/local/lib/node_modules/miniflare/node_modules/@miniflare/shared/src/event.ts:29:9
    at EventTarget.<anonymous> (/usr/local/lib/node_modules/miniflare/node_modules/@miniflare/shared/src/event.ts:77:9)
@leaysgur
Copy link
Contributor

leaysgur commented Feb 7, 2022

I've investigated a little and found that import HTML from "chat.html" causes the problem.

This is my repro: https://github.com/leader22/miniflare-import_html-repro

Since chat.html is a completely static file, you can export it as string from chat.html.mjs as a workaround.

By the way, import "foo.html" syntax is Cloudflare Workers specific features...? 🤔

@mrbbot
Copy link
Contributor

mrbbot commented Feb 7, 2022

Hey! 👋 Thank you both for reporting and investigating this. Will try look into this soon. What versions of Node were you using? I'm surprised tests didn't catch this. 😕

@mrbbot mrbbot added the bug Something isn't working label Feb 7, 2022
@mrbbot mrbbot closed this as completed in 4eb120b Feb 7, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Feb 7, 2022

Hey! 👋 I've just released version 2.3.0 including a fix for this. You can find the full changelog here.

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