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

corsify creating unused readable stream #26

Open
0xCaliburSigma opened this issue Aug 14, 2024 · 4 comments
Open

corsify creating unused readable stream #26

0xCaliburSigma opened this issue Aug 14, 2024 · 4 comments

Comments

@0xCaliburSigma
Copy link

Error:

A ReadableStream branch was created but never consumed. Such branches can be created, for instance, by calling the tee() method on a ReadableStream, or by calling the clone() method on a Request or Response object. If a branch is created but never consumed, it can force the runtime to buffer the entire body of the stream in memory, which may cause the Worker to exceed its memory limit and be terminated. To avoid this, ensure that all branches created are consumed.

  • Unused stream created:
    at corsify (index.js:62:113)
    at index.js:305:93

Code:

const { preflight, corsify } = cors({ origin: '*', allowMethods: ['GET'] });

const router = AutoRouter({
  base: '/',
  before: [preflight, customMiddleware],
  finally: [corsify]
});
@0xCaliburSigma
Copy link
Author

Removing corsify from the AutoRouter configuration silences this

@0xCaliburSigma
Copy link
Author

It isn't cause of my custom middleware either cause I removed it and the error persisted

@proatwork
Copy link

I'm also facing this on "^5.0.18"

@susickypavel
Copy link

susickypavel commented Oct 5, 2024

Also facing the same issue If I use waitUntil in Cloudflare workers.

EDIT: itty-router@5.0.16 works in this case, but has different issues there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants