You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Context: This issue was originally reported by @atinux for Nuxt Hub, we have later narrowed down this issue to nitro-cf-dev and then finally to this minimal reproduction.)
Description
Using wrangler.getBindingsProxy to read R2 bucket data, the readable stream will be stuck on big sizes (1MB+) if used with concurrency of 2+ promises. The second stream will never end and the Node.js process is stuck. This issue does not happen in production.
import{getPlatformProxy}from"wrangler"// tested on 3.37.0constproxy=awaitgetPlatformProxy({})const{BLOB: bucket}=proxy.envconsole.log('Fetching cat image...')constimgReadableStream=awaitfetch('https://images.unsplash.com/photo-1579168765467-3b235f938439?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=yoo-hoo-E3LcqpQxtTU-unsplash.jpg').then(r=>r.body)console.log('Converting image to buffer...')constbuff=awaitreadableStreamToBuff(imgReadableStream)console.log('Buffer length (response):',buff.length)console.log('Putting cats to the bucket...')awaitbucket.put('cat1.jpg',buff.buffer)awaitbucket.put('cat2.jpg',buff.buffer)console.log('Reading from bucket...')// This will make process hangconst[cat1,cat2]=awaitPromise.all([bucket.get('cat1.jpg').then(obj=>readableStreamToBuff(obj.body)),bucket.get('cat2.jpg').then(obj=>readableStreamToBuff(obj.body)),])// This works// const cat1 = await bucket.get('cat1.jpg').then(obj => readableStreamToBuff(obj.body))// const cat2 = await bucket.get('cat2.jpg').then(obj => readableStreamToBuff(obj.body))console.log('Buffer length (bucket):',[cat1.length,cat2.length])awaitproxy.dispose()asyncfunctionreadableStreamToBuff(stream){console.log('reading stream to buffer... ')constchunks=[];awaitstream.pipeTo(newWritableStream({write(chunk){process.stdout.write(` +${chunk.length}`)chunks.push(chunk);},close(){console.log('stream close')}}),)console.log('stream read!')returnBuffer.concat(chunks);}
(Context: This issue was originally reported by @atinux for Nuxt Hub, we have later narrowed down this issue to nitro-cf-dev and then finally to this minimal reproduction.)
Description
Using
wrangler.getBindingsProxy
to read R2 bucket data, the readable stream will be stuck on big sizes (1MB+) if used with concurrency of 2+ promises. The second stream will never end and the Node.js process is stuck. This issue does not happen in production.Minimal reproduction
I have made a repo with two simple (plain script and plain node server) examples that reproduce this. https://github.com/pi0/cf-proxy-repro
(tested on
wrangler@3.37.0
)Used with parallel
Promise.all
: (process hangs)Used without parallel promises: (works)
Possible workaround
Using a mutex to run only one at a time. Used for nitro-cloudflare-dev
The text was updated successfully, but these errors were encountered: