Skip to content

fix(shared): end workspace retry waits when the request aborts - #738

Merged
ditadi merged 3 commits into
mainfrom
fix/shared-abortable-retry-wait
Nov 16, 2026
Merged

ditadi merged 3 commits into
mainfrom
fix/shared-abortable-retry-wait

Conversation

@ditadi

@ditadi ditadi commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

sendWithRetry in packages/shared/src/workspace-client/modular.ts now ends a 429/transient backoff wait as soon as the request's signal aborts, and rejects with signal.reason, like the SDK's own retry sleep in ops/execute.js. A signal that is already aborted when the error arrives rejects the same way. Either way it clears the timer and the listener and sends nothing more. Retry conditions, backoff, deadline, and the streamed-body bypass are unchanged.

Why: the wait was a bare setTimeout. A request-path timeout such as AbortSignal.timeout(10_000) could be held up to ~10 s past its deadline before the next send failed on the aborted signal. The database plugin's caller check (#689) runs on this path. Rejecting with the reason, instead of returning the last 429, keeps a cancel or timeout recognizable to callers that match on the abort error, such as _rethrowStatementError in the SQL warehouse connector and the analytics plugin.

Testing: new tests in modular.test.ts.

  • An abort mid-backoff rejects at once with the signal's reason, for both a plain cancel (AbortError) and a TimeoutError reason, with no second send and no pending timer.
  • A 429 on an already aborted signal rejects without waiting.
  • A signal that never aborts still retries to success and leaves no abort listener.

The first two fail on the previous version of this PR. pnpm build, pnpm -r typecheck, pnpm check, and pnpm vitest run (6220 passed, 1 skipped) pass.

This pull request and its description were written by Isaac.

The 429 backoff slept on a bare setTimeout, so a caller's abort was held
for the rest of the wait and then failed on the next send.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: ditadi <victordperd@gmail.com>
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.3 MB (+813 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.3 MB (-7.3 KB) 484 KB (-1.7 KB)
Type declarations 481 KB (+8.6 KB) 173 KB (+2.8 KB)
Source maps 2.6 MB (-2.1 KB) 902 KB (+535 B)
Other 11 KB 3.7 KB
Total 4.5 MB (-905 B) 1.5 MB (+1.6 KB)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 111 KB (+71 B) 2.5 KB 114 KB (+71 B) external 359 KB (+186 B)
./beta 113 KB (-706 B) 484 B 113 KB (-706 B) external 336 KB (-2.9 KB)
./testing 46 KB (+77 B) 34 KB 81 KB (+77 B) external 233 KB (+186 B)
./tsdown 520 B 0 B 520 B external 813 B
./type-generator 27 KB (+22 B) 0 B 27 KB (+22 B) external 79 KB (+186 B)

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 107 KB
. utils.js initial 4.6 KB
. remote-tunnel-manager.js lazy 2.5 KB
./beta beta.js initial 92 KB
./beta modular.js initial 6.1 KB
./beta stream-manager.js initial 5.9 KB
./beta service-context.js initial 4.3 KB
./beta databricks.js initial 3.3 KB
./beta client.js initial 647 B
./beta index.js initial 20 B
./beta supervisor-api.js lazy 191 B
./beta databricks.js lazy 178 B
./beta index.js lazy 115 B
./testing manifest.js initial 33 KB
./testing index.js initial 10 KB
./testing wide-event-emitter.js initial 2.9 KB
./testing index.js lazy 30 KB
./testing remote-tunnel-manager.js lazy 2.5 KB
./testing utils.js lazy 1.8 KB
./tsdown index.js initial 520 B
./type-generator index.js initial 27 KB

@databricks/appkit-ui

npm tarball (packed): 406 KB (-2.4 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 438 KB (-1.9 KB) 150 KB (-774 B)
Type declarations 271 KB (-920 B) 100 KB (-222 B)
Source maps 865 KB (-4.5 KB) 291 KB (-1.4 KB)
CSS 16 KB 3.2 KB
Total 1.6 MB (-7.3 KB) 544 KB (-2.4 KB)
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
./js 5.3 KB 49 KB 55 KB 208 KB 14 KB
./js/beta 2.1 KB 0 B 2.1 KB 0 B 5.0 KB
./react 441 KB 49 KB 489 KB 1.4 MB 179 KB
./react/beta 14 KB (-195 B) 0 B 14 KB (-195 B) 25 KB 15 KB (-556 B)

Chunks:

Entry Chunk Load Size (gz)
./js index.js initial 5.2 KB
./js chunk initial 120 B
./js apache-arrow lazy 49 KB
./js/beta beta.js initial 2.1 KB
./react index.js initial 439 KB
./react tslib initial 2.1 KB
./react apache-arrow lazy 49 KB
./react/beta beta.js initial 14 KB

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks CLI):

gh run download 43965458942 -R databricks/appkit -n appkit-template-0.96.0-pr.67801b0-fix-shared-abortable-retry-wait-738 -D appkit-pr-738 \
  && unzip -o "appkit-pr-738/appkit-template-0.96.0-pr.67801b0-fix-shared-abortable-retry-wait-738.zip" -d "appkit-pr-738" \
  && databricks apps init --template "appkit-pr-738"

The template pins @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

@calvarjorge calvarjorge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ending the wait as soon as the signal aborts is the right fix, and the timer and listener cleanup looks correct. One concern, inline: an abort during the wait now comes back as the 429, not as an abort error.

Returning the last 429 turned a cancel or timeout during a backoff into
ApiError(429), which callers that recognize an abort by its error (the
SQL warehouse connector, analytics) reported as a failure. The wait now
rejects with signal.reason, like the SDK's own retry sleep.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: ditadi <victordperd@gmail.com>
@ditadi
ditadi requested a review from calvarjorge November 16, 2026 15:39

@calvarjorge calvarjorge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, 5fe6012 covers both comments. The wait now rejects with signal.reason, so a cancel or timeout reaches the caller as the abort, and the tests cover a cancel, a timeout and an already-aborted signal. LGTM.

@ditadi
ditadi merged commit a535cc9 into main Nov 16, 2026
20 of 21 checks passed
@ditadi
ditadi deleted the fix/shared-abortable-retry-wait branch November 16, 2026 22:32
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

Successfully merging this pull request may close these issues.

2 participants