@@ -128,8 +128,8 @@ export class DenoWorker {
128128 private _options : DenoWorkerOptions ;
129129 private _ports : Map < number | string , MessagePortData > ;
130130 private _terminated : boolean ;
131- private _stdout : Duplex ;
132- private _stderr : Duplex ;
131+ private _stdout : Readable ;
132+ private _stderr : Readable ;
133133
134134 /**
135135 * Creates a new DenoWorker instance and injects the given script.
@@ -139,9 +139,9 @@ export class DenoWorker {
139139 this . _onmessageListeners = [ ] ;
140140 this . _pendingMessages = [ ] ;
141141 this . _available = false ;
142- this . _stdout = new Duplex ( ) ;
142+ this . _stdout = new Readable ( ) ;
143143 this . _stdout . setEncoding ( 'utf-8' ) ;
144- this . _stderr = new Duplex ( ) ;
144+ this . _stderr = new Readable ( ) ;
145145 this . _stdout . setEncoding ( 'utf-8' ) ;
146146 this . _stderr . setEncoding ( 'utf-8' ) ;
147147 this . _options = Object . assign (
@@ -156,17 +156,6 @@ export class DenoWorker {
156156 options || { }
157157 ) ;
158158
159- if ( this . _options . logStdout ) {
160- this . stdout . on ( 'data' , ( data ) => {
161- console . log ( '[deno]' , data ) ;
162- } ) ;
163- }
164- if ( this . _options . logStderr ) {
165- this . stderr . on ( 'data' , ( data ) => {
166- console . log ( '[deno]' , data ) ;
167- } ) ;
168- }
169-
170159 this . _ports = new Map ( ) ;
171160 this . _httpServer = createServer ( ) ;
172161 this . _server = new WSServer ( {
@@ -307,8 +296,19 @@ export class DenoWorker {
307296 ...scriptArgs ,
308297 ] ) ;
309298
310- this . _process . stdout ?. pipe ( this . _stdout ) ;
311- this . _process . stderr ?. pipe ( this . _stderr ) ;
299+ this . _stdout = < Readable > this . _process . stdout ;
300+ this . _stderr = < Readable > this . _process . stderr ;
301+
302+ if ( this . _options . logStdout ) {
303+ this . stdout . on ( 'data' , ( data ) => {
304+ console . log ( '[deno]' , data ) ;
305+ } ) ;
306+ }
307+ if ( this . _options . logStderr ) {
308+ this . stderr . on ( 'data' , ( data ) => {
309+ console . log ( '[deno]' , data ) ;
310+ } ) ;
311+ }
312312 } ) ;
313313 }
314314
0 commit comments