Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/duckdb-wasm/src/parallel/async_bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ export class AsyncDuckDB implements AsyncDuckDBBindings {
this._pendingRequests.clear();
}

/** Is in detached state, no worker defined */
public isDetached(): boolean {
return !this._worker;
}

/** Reset the duckdb */
public async reset(): Promise<null> {
const task = new WorkerTask<WorkerRequestType.RESET, null, null>(WorkerRequestType.RESET, null);
Expand Down
5 changes: 5 additions & 0 deletions packages/duckdb-wasm/src/parallel/async_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export class AsyncDuckDBConnection {
});
let header = await this._bindings.startPendingQuery(this._conn, text, allowStreamResult);
while (header == null) {
// Avoid infinite loop on detached state
if (this._bindings.isDetached()) {
console.error('cannot send a message since the worker is not set!');
return undefined as any;
}
header = await this._bindings.pollPendingQuery(this._conn);
}
const iter = new AsyncResultStreamIterator(this._bindings, this._conn, header);
Expand Down