HTHou commented on PR #23: URL: https://github.com/apache/iotdb-client-nodejs/pull/23#issuecomment-5138378479
I found a lifecycle race around the new early return in `Connection.open()`. If `close()` runs after `openSession()` has set `sessionId` but before the pending `requestStatementId()` callback completes, `close()` clears `sessionId`, `client`, and `connection`. The pending setup then resumes and sets `isConnected = true`. A later `open()` returns immediately at the new `if (this.isConnected)` check even though `isOpen()` is false, so it does not reconnect. I reproduced this with a deferred `requestStatementId` callback: after the interleaving, a second `open()` left `createConnection` at one call and the connection remained closed. Changing the fast-path guard to the complete invariant, e.g. `if (this.isOpen())`, makes the regression test pass. Alternatively, `close()` could be coordinated with `openingPromise`. Could we handle this interleaving and add a regression test for it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
