File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/pg-query-stream/test Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ helper('early close', function (client) {
61
61
} )
62
62
63
63
it ( 'can destroy stream while reading an error' , function ( done ) {
64
- var stream = new QueryStream ( 'SELECT * from pg_sleep(1), basdfasdf;' )
64
+ var stream = new QueryStream ( 'SELECT * from pg_sleep(1), basdfasdf;' )
65
65
client . query ( stream )
66
66
stream . on ( 'data' , ( ) => done ( new Error ( 'stream should not have returned rows' ) ) )
67
67
stream . once ( 'error' , ( ) => {
@@ -70,4 +70,19 @@ helper('early close', function (client) {
70
70
setTimeout ( done , 100 )
71
71
} )
72
72
} )
73
+
74
+ it ( 'does not crash when destroying the stream immediately after calling read' , function ( done ) {
75
+ var stream = new QueryStream ( 'SELECT * from generate_series(0, 100), pg_sleep(1);' )
76
+ client . query ( stream )
77
+ stream . on ( 'data' , ( ) => done ( new Error ( 'stream should not have returned rows' ) ) )
78
+ stream . destroy ( )
79
+ stream . on ( 'close' , done )
80
+ } )
81
+
82
+ it ( 'does not crash when destroying the stream before its submitted' , function ( done ) {
83
+ var stream = new QueryStream ( 'SELECT * from generate_series(0, 100), pg_sleep(1);' )
84
+ stream . on ( 'data' , ( ) => done ( new Error ( 'stream should not have returned rows' ) ) )
85
+ stream . destroy ( )
86
+ stream . on ( 'close' , done )
87
+ } )
73
88
} )
You can’t perform that action at this time.
0 commit comments