Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send function make infinite loop on destroyed worker #1970

Open
bluehat974 opened this issue Mar 2, 2025 · 0 comments
Open

send function make infinite loop on destroyed worker #1970

bluehat974 opened this issue Mar 2, 2025 · 0 comments

Comments

@bluehat974
Copy link

bluehat974 commented Mar 2, 2025

What happens?

In the send function, when the worker is destroyed, there is a while loop which fail indefinitely, making the website failling completely

Destroy can occur any time and the send function can be called in a promise later.

// Infinite error like this
hook.js:608 cannot send a message since the worker is not set!
overrideMethod      @hook.js:608
postTask            @async_bindings.ts:103
pollPendingQuery    @async_bindings.ts:422
send                @async_connection.ts:65

To Reproduce

There is a while loop in the send function which doesnt stop when there is an error

https://github.com/duckdb/duckdb-wasm/blob/main/packages/duckdb-wasm/src/bindings/connection.ts#L43

while (header == null) {
    header = await new Promise((resolve, reject) => {
        try {
            resolve(this._bindings.pollPendingQuery(this._conn));
        } catch (e: any) {
            console.log(e);
            reject(e);
        }
    });
 }

https://github.com/duckdb/duckdb-wasm/blob/main/packages/duckdb-wasm/src/parallel/async_connection.ts#L64

while (header == null) {
    header = await this._bindings.pollPendingQuery(this._conn);
}

Destroy a worker and call send function

const c = await db.connect();
await db.terminate(); // Usually called somewhere else
await c.send('SELECT 1;');
await c.close();

Browser/Environment:

Chrome 133

Device:

Macbook

DuckDB-Wasm Version:

1.29.1-dev17.0

DuckDB-Wasm Deployment:

https://shell.duckdb.org/

Full Name:

Fontaine Audrien

Affiliation:

Unify

@bluehat974 bluehat974 changed the title send function make Infinite loop on destroyed worker send function make infinite loop on destroyed worker Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant