Skip to content

fix(indexeddb): fix WebKit browser test failures by safely handling IDBRequest.error access#50

Merged
azu merged 10 commits intomasterfrom
claude/fix-webkit-download-ZWdbW
Jan 17, 2026
Merged

fix(indexeddb): fix WebKit browser test failures by safely handling IDBRequest.error access#50
azu merged 10 commits intomasterfrom
claude/fix-webkit-download-ZWdbW

Conversation

@azu
Copy link
Owner

@azu azu commented Jan 17, 2026

  • Fix WebKit browser test failures caused by accessing IDBRequest.error before readyState === "done", which throws InvalidStateError in WebKit (strict W3C spec compliance)
  • Add getRequestError helper function that safely wraps error access with readyState check
  • Fix dropInstance.onblocked to not reject - onblocked means waiting for other connections to close, not a failure
  • Update playwright-test from ^12.1.1 to ^14.1.12 for better WebKit compatibility
  • Add playwright install --with-deps steps for Firefox and WebKit in CI

Add explicit `playwright install --with-deps` steps for Firefox and
WebKit CI jobs to fix test failures:

- Firefox on Ubuntu was missing libdbus-glib-1-2 system dependency
- WebKit on macOS had "Page closed" errors due to browser setup issues

The --with-deps flag ensures both browser binaries and system
dependencies are properly installed before running tests.
@azu azu added the Type: CI Changes to CI configuration files and scripts label Jan 17, 2026
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 17, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1b87b51:

Sandbox Source
kvs-example-basic Configuration

@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2026

size-limit report 📦

Path Size
packages/env/module/browser.js 1.16 KB (+8.9% 🔺)
packages/indexeddb/module/index.js 1.15 KB (+8.79% 🔺)
packages/localstorage/module/index.js 860 B (0%)

Update playwright-test from ^12.1.1 to ^14.1.12 in all packages to fix
WebKit test failures on macOS. The older version bundled playwright-core
with WebKit 1921 which is incompatible with newer macOS runners.

The newer playwright-test includes a more recent playwright-core with
WebKit builds that are compatible with macos-latest (macos-14).
Reset kvsTestCase.ref.current to null after cleanup to prevent operating
on stale database instances. WebKit is strict about database connection
state and throws InvalidStateError when trying to perform operations on
a closing connection.

Also silence cleanup errors since they're expected when the database
is already closed/deleted.
- Remove double-resolve: Previously, the promise was resolved in both
  transaction.oncomplete and onsuccess, causing timing issues in WebKit
- Move onUpgrade callback to onsuccess handler to ensure database is
  fully ready before calling user code
- Fix onblocked handler to not access openRequest.error before the
  request has finished, which caused InvalidStateError in WebKit
- Use variables to track upgrade state instead of relying on closure
  scope within oncomplete
In WebKit, accessing request.error in onblocked handlers throws
InvalidStateError because the request hasn't finished yet - it's just
waiting for other connections to close.

- Fix dropInstance onblocked to use a generic error message
- Fix test to ignore deleteDatabase errors during cleanup
Add getRequestError helper that checks request.readyState === "done"
before accessing request.error. This prevents InvalidStateError in
WebKit when the error property is accessed before the request finishes.

Each call site now includes a descriptive fallback message to identify
where the error originated if readyState is unexpectedly not "done".
…sages

- Make fallbackMessage required to ensure all error cases are descriptive
- Use Error cause to preserve the original DOMException while adding context
- Standardize all error messages to "Failed to ..." format for consistency
The onblocked event for deleteDatabase means waiting for other
connections to close, not a failure. The delete will proceed
once all connections are closed, so we should wait for onsuccess
or onerror instead of rejecting immediately.
Revert the structural changes that moved onUpgrade from
transaction.oncomplete to onsuccess. The original structure
using transaction.oncomplete is correct and the user requested
only the getRequestError helper without restructuring openDB.
@azu azu changed the title fix(ci): install playwright browser dependencies before tests fix(indexeddb): fix WebKit browser test failures by safely handling IDBRequest.error access Jan 17, 2026
@azu azu added the Type: Bug Bug or Bug fixes label Jan 17, 2026
@azu azu merged commit 9f68726 into master Jan 17, 2026
12 checks passed
@azu azu deleted the claude/fix-webkit-download-ZWdbW branch January 17, 2026 22:58
This was referenced Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes Type: CI Changes to CI configuration files and scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants