Repository navigation
feat: support Symbol.asyncDispose on client, session, and operation - #586
Conversation
DBSQLClient, DBSQLSession, and DBSQLOperation (and the IDBSQLClient, IDBSQLSession, and IOperation interfaces) gain [Symbol.asyncDispose](), which delegates to close(), so `await using` works on both backends. Disposing an already-closed object is a no-op. The published typings declare SymbolConstructor.asyncDispose themselves, so consumers don't need TypeScript's esnext.disposable lib or a recent @types/node. Fixes #331 Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
@bot Please mention adding esnext.disposable to compilerOptions.lib when the consumer’s typings don’t already provide disposable declarations. Otherwise, the documented example can fail even with TypeScript 5.2+. |
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
|
Pushed Started from 82b6e7b. I added a note to the README's "Automatic cleanup with |
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
|
Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase ( |
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
ec3a551 to
02233d7
Compare
With the README’s nested await using example, an operation whose close always rejects is retried three times, while session/backend closure and client telemetry release are skipped. Can we continue closing other resources and always attempt parent cleanup, then report the collected failures? Please add a regression test for this path. If deferred, qualify the README’s cleanup guarantee and mention SuppressedError when both the body and disposal fail.
This test enshrines disposal after cancellation as a no-op. Cancellation already removes the operation from its session’s collection, and closeInternal() skips cancelled operations, so neither disposal nor session cleanup invokes the operation |
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
|
Pushed Started from 02233d7. Fixed both items. |
|
@bot • Restore IDBSQLClient, IDBSQLSession, and IOperation to their original contracts. Keep Symbol.asyncDispose on the concrete classes. • Give concrete class methods disposable return types: connect(): Promise, openSession(): Promise, and operation factories—including metadata methods— returning Promise. Update private staging helpers as needed. • Keep the symbol declaration shim reachable from the emitted class declarations. Supported Node versions already provide the runtime symbol. • Add consumer type tests against emitted dist declarations: legacy interface implementations/mocks still compile, explicit disposal works without esnext.disposable, and an await using client → session → operation chain compiles with it. • Update the CHANGELOG to remove the requirement for custom interface implementations to add disposal. Retain the cleanup-failure and cancellation fixes. Check subclass override compatibility before narrowing existing class methods; if that introduces another source break, use an additive disposable factory/helper instead. |
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
|
Pushed Started from ca5fa37. IDBSQLClient/IDBSQLSession/IOperation are back to their original contracts; the concrete classes keep Symbol.asyncDispose and now import the shim themselves. I didn't narrow the return types: a test showed it breaks existing subclasses (TS2416). So I added an exported asyncDisposable() helper. New consumer type tests compile in-memory fixtures against freshly emitted declarations: legacy implementations, mocks and subclasses, and explicit disposal, with and without esnext.disposable, plus an await using chain with it. CHANGELOG and README are updated; the cleanup and cancel fixes are kept. npm test (1596), type-check and prettier pass. Lint failed before checking any file: ESLint picked up an .eslintrc in the folder above the check |
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Adds
Symbol.asyncDisposetoDBSQLClient,DBSQLSession, andDBSQLOperation, soawait usingcalls their existingclose()methods on scope exit. This covers both the Thrift and kernel backends and preserves the existing close and cancellation behavior.Public interfaces and factory return types remain compatible with existing implementations, mocks, and subclasses. In TypeScript, use the exported
asyncDisposable()helper for interface-typed results:The published declarations include a
Symbol.asyncDisposeshim for consumers withoutesnext.disposable. The README explains the runtime/compiler requirements and how disposal errors propagate.Validation: 366 focused unit tests pass, including consumer declaration tests, plus build, type-check, lint, and formatting. Live warehouse tests were not rerun.
Fixes #331.