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
{{ message }}
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.
I'm trying my luck using async iterators, with the end goal to use for-await.
However, a peculiar behaviour occurred while awaiting within the loop.
I am not sure if this is an internal bug or if a change (which occurred in v11.5) changed the behaviour of async iterator which in turn either pg-cursor or pg-query-stream did not follow.
I posted a bug report in node repo because I wanted to understand the change (intended or not), but I'll double post the bug here for clarity and perhaps its an easy fix outside of internals?
Here's a reproducible:
constassert=require('assert')const{ Client }=require('pg')constQueryStream=require('pg-query-stream')asyncfunctionmain(){constclient=newClient()awaitclient.connect()constsql='select * from generate_series(1, $1)'constn=10// num rows to generateconstquery=newQueryStream(sql,[n])conststream=client.query(query)leti=0forawait(constrowofstream){console.log(stream._readableState.length)i+=1awaitnewPromise((resolve)=>setTimeout(()=>resolve(),0))// ^-- This await breaks it all in v10.16, v11.5+ but works in from v11.0 to v.11.4}awaitclient.end()assert.strictEqual(i,n)}if(!module.parent){main()}
Hi,
I'm trying my luck using async iterators, with the end goal to use
for-await
.However, a peculiar behaviour occurred while awaiting within the loop.
I am not sure if this is an internal bug or if a change (which occurred in v11.5) changed the behaviour of async iterator which in turn either pg-cursor or pg-query-stream did not follow.
I posted a bug report in node repo because I wanted to understand the change (intended or not), but I'll double post the bug here for clarity and perhaps its an easy fix outside of internals?
Here's a reproducible:
$ node -v v11.5.0 $ node what.js 9 8 (node:21383) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal: 2 !== 10 at main (/Users/fl0w/async-iterator-stream/what.js:24:10) at process.internalTickCallback (internal/process/next_tick.js:77:7)
Refs: nodejs/node#29410
The text was updated successfully, but these errors were encountered: