Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: b9d8178a06354839d750efb4911eefda2991e26b https://github.com/WebKit/WebKit/commit/b9d8178a06354839d750efb4911eefda2991e26b Author: Sihui Liu <sihui_...@apple.com> Date: 2025-03-27 (Thu, 27 Mar 2025)
Changed paths: A LayoutTests/storage/indexeddb/resources/transaction-abort-on-worker-terminate.js A LayoutTests/storage/indexeddb/transaction-abort-on-worker-terminate-expected.txt A LayoutTests/storage/indexeddb/transaction-abort-on-worker-terminate.html M Source/WebCore/Modules/indexeddb/IDBTransaction.cpp Log Message: ----------- IndexedDB in Worker commits when thread is terminated https://bugs.webkit.org/show_bug.cgi?id=288682 rdar://146354005 Reviewed by Brady Eidson. According to spec, IDBTransaction should be committed automatically when there is no more pending request on the transaction, and a request is finished when its result is dispatched via event handler. Normally, if the event handler resolves a Promise and client starts new request when the Promise is resolved, the new request can keep transaction from automatic commit. In the case of Worker termination, WebKit might stop script execution early, so that the new request might not get created as expected. See the new test for an example: the Worker script is stopped at sleep(), before new IDBRequest is created by getRecord(). Because the new request is not created, WebKit would think there is no more request after event dispatch, and continue to commit transaction automatically. This is not the expected behavior, given that client actually wants to schedule more request for the transaction. For consistency, it's better abort transaction instead of committing it. To fix this, this patch disables automatic commit of transaction if Worker is terminating and script execution has stopped. In this case, the transaction will be aborted in IDBTransaction::stop() (when ActiveDOMObjects are stopped). Test: storage/indexeddb/transaction-abort-on-worker-terminate.html * LayoutTests/storage/indexeddb/resources/transaction-abort-on-worker-terminate.js: Added. (async openDatabase): (async getRecord): (async writeRecord): (async deleteRecord): (async executeTransaction): (sleep): (async test): * LayoutTests/storage/indexeddb/transaction-abort-on-worker-terminate-expected.txt: Added. * LayoutTests/storage/indexeddb/transaction-abort-on-worker-terminate.html: Added. * Source/WebCore/Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::autoCommit): Canonical link: https://commits.webkit.org/292795@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes