kwhitley / itty.dev

Documentation for itty ecosystem.
16 stars 13 forks source link

corsify creating unused readable stream #26

Open 0xCaliburSigma opened 4 weeks ago

0xCaliburSigma commented 4 weeks ago

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.

Code:

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

const router = AutoRouter({
  base: '/',
  before: [preflight, customMiddleware],
  finally: [corsify]
});
0xCaliburSigma commented 4 weeks ago

Removing corsify from the AutoRouter configuration silences this

0xCaliburSigma commented 4 weeks ago

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

proatwork commented 2 days ago

I'm also facing this on "^5.0.18"