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
This was not easy to figure out because it didn't produce any errors. However I found that the issue happens when you call the method as a Promise.
The Promise needs to have either resolve or reject method called in order for the execution to proceed. However when you run the code above the handleCallback method is run in the "close" event handler at this line of tcpport.js. This call gets executed before the await client.close() line is reached and is that call via the this._port.close(callback) call at this line of index.js that sets the this.callback. So the this.callback is never run.
If you change the line closing the client in the code above to client.close(() => {}) avoiding in this way the Promise the program behaves as expected.
I'm not sure what could be the best way to fix this. My guess is that the callback should be called in the close method of TCPPort. In this way the timing is completely dependent from the user code. However I'm not sure what could be the implications of doing this in the rest of the code.
Thank you.
The text was updated successfully, but these errors were encountered:
When I try to run the following code the process exits (note the
while (true)
loop around the connection code):This was not easy to figure out because it didn't produce any errors. However I found that the issue happens when you call the method as a Promise.
The Promise needs to have either
resolve
orreject
method called in order for the execution to proceed. However when you run the code above thehandleCallback
method is run in the "close" event handler at this line oftcpport.js
. This call gets executed before theawait client.close()
line is reached and is that call via thethis._port.close(callback)
call at this line ofindex.js
that sets thethis.callback
. So thethis.callback
is never run.If you change the line closing the client in the code above to
client.close(() => {})
avoiding in this way the Promise the program behaves as expected.I'm not sure what could be the best way to fix this. My guess is that the callback should be called in the
close
method of TCPPort. In this way the timing is completely dependent from the user code. However I'm not sure what could be the implications of doing this in the rest of the code.Thank you.
The text was updated successfully, but these errors were encountered: