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
11 changes: 11 additions & 0 deletions .changeset/automerge-worker-nudge-grace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@inkandswitch/patchwork-bootloader": patch
"@inkandswitch/patchwork": patch
"@inkandswitch/patchwork-e2e": patch
---

The service worker no longer mistakes a booting automerge worker for a missing one. The worker only asked for its lock once its whole import graph (most of a megabyte) had loaded, so asset requests made in that window found no lock and logged "no automerge worker; asking tabs to start one". Each tab then dropped its connection to the booting worker and reconnected sync. In a single tab that happened on every reload.

The worker's script, `automerge-protocol-handler-worker.js`, is now a small module that takes the lock and holds on to connecting tabs before it imports the worker itself, now `@inkandswitch/patchwork-bootloader/automerge-protocol-handler`. The vite plugin emits that as a second file, `automerge-protocol-handler.js`, beside the first. As a backstop, the service worker waits three seconds before nudging, and only nudges if the request is still unanswered and there's still no lock. The nudge is throttled to once every five seconds, however many requests are waiting. Before, every request that raced the same cold start got past the throttle and logged its own nudge.

The e2e suite gains `automerge-worker.spec.ts`, which checks that the worker holds its lock once a tab is up and that a request racing a cold worker boot isn't reported as a missing worker.
8 changes: 8 additions & 0 deletions .changeset/coalesce-package-lookups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@inkandswitch/patchwork-filesystem": patch
"@inkandswitch/patchwork-bootloader": patch
---

Package heads lookups no longer pile up on a busy automerge worker. A package doc that's still syncing, as everything is on a fresh login, reports a change with every batch that arrives. The `ModuleWatcher` started a lookup for each one, and the automerge worker ran each as a full resolve with its own 30-second timeout. A worker slowed by the login sync then timed them all out, and each logged its own 557.

The `ModuleWatcher` now runs one change-triggered lookup per package at a time. Changes that land while one is in flight collapse into a single lookup after it. The automerge worker shares one resolve between concurrent requests for the same package url without heads, so tabs asking at once wait on the same lookup.
5 changes: 5 additions & 0 deletions .changeset/package-lookup-reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inkandswitch/patchwork-filesystem": patch
---

When the service worker can't redirect a package url to its heads, the error now includes the automerge worker's reason (the first line of its 557 body — e.g. the doc is unavailable, or the resolve timed out) instead of only the status.
70 changes: 70 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: e2e

permissions:
contents: read

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SHELL_REPO: inkandswitch/patchwork.inkandswitch.com
SITE_DIR: sites/patchwork.inkandswitch.com

jobs:
e2e:
name: e2e (${{ matrix.browser }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: ${{ env.SHELL_REPO }}
path: ${{ env.SITE_DIR }}

- uses: pnpm/action-setup@v4
with:
run_install: false

- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm

# The same build the preview deploys: the shell, against this branch's
# packages.
- name: build the shell against this branch's packages
run: |
node .github/scripts/use-workspace-packages.mjs "$GITHUB_WORKSPACE/$SITE_DIR"
pnpm install --no-frozen-lockfile
pnpm build

- name: install ${{ matrix.browser }}
working-directory: packages/e2e
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}

- name: run the suite
working-directory: packages/e2e
env:
PATCHWORK_E2E_SITE_DIR: ${{ github.workspace }}/${{ env.SITE_DIR }}
run: pnpm exec playwright test --project=${{ matrix.browser }}

- uses: actions/upload-artifact@v4
if: failure()
with:
name: e2e-${{ matrix.browser }}
path: |
packages/e2e/playwright-report/
packages/e2e/test-results/
retention-days: 7
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
4 changes: 4 additions & 0 deletions core/bootloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"import": "./dist/automerge-protocol-handler-worker.js",
"types": "./dist/automerge-protocol-handler-worker.d.ts"
},
"./automerge-protocol-handler": {
"import": "./dist/automerge-protocol-handler.js",
"types": "./dist/automerge-protocol-handler.d.ts"
},
"./module-loader": {
"import": "./dist/module-loader.js",
"types": "./dist/module-loader.d.ts"
Expand Down
Loading
Loading