fix(routerlicious-driver): retry transient network errors in restWrapper#27631
fix(routerlicious-driver): retry transient network errors in restWrapper#27631arafat-java wants to merge 2 commits into
Conversation
Ported from a fix validated in a downstream fork (concurrent-editing microsoft#232), adapted to this repo's current restWrapper.ts/restWrapper.spec.ts conventions.
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (212 lines, 2 files), I've queued these reviewers:
How this works
|
🔭 PR Review Fleet ReportNote This report is generated by an experimental AI review fleet and is provided as a beta feature. Findings are a starting point for discussion, not a gate. Use your own judgement. Verdict: ❌ Request Changes 0 Alert, 1 Stop, 1 Caution Findings
|
| response: result, | ||
| duration: performanceNow() - perfStart, | ||
| }; | ||
| } catch (error: any) { |
There was a problem hiding this comment.
for improved type safety, type errors as unknown not any
| private static readonly maxNetworkErrorAttempts = 3; | ||
|
|
||
| /** Delay between transient network-error retries. */ | ||
| private static readonly networkErrorRetryDelayMs = 250; |
There was a problem hiding this comment.
In networking, I generally expect https://en.wikipedia.org/wiki/Exponential_backoff unless there is some known category of issue this timeout is selected to be relevant to. Might be good to document why this specific duration makes sense.
Might also be good to document the consequences of setting this or the retry count higher (I assume it can result in something taking longer before failing, or maybe hiding flakey service issues?).
Anyway, this isn't an area I work in, so I'm no expert here, those are just my thoughts.
|
/azp run Build - protocol-definitions,Build - test-tools,server-gitrest,server-gitssh,server-historian,server-routerlicious,Build - client packages,repo-policy-check |
|
/azp run Build - api-markdown-documenter,Build - benchmark-tool,Build - build-common,Build - build-tools,Build - common-utils,Build - eslint-config-fluid,Build - eslint-plugin-fluid |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
Bundle size comparisonBase commit: The PR's CI build failed — fix the build and the comment will update once the next run succeeds. |
How contribute to this repo.
Guidelines for Pull Requests.
Description
Port of a fix validated in a downstream fork (concurrent-editing, commit f71f3c4), adapted to this repo's current
restWrapper.ts/restWrapper.spec.tsconventions (which have diverged from the vendored copy — different imports, sinon-based test mocking instead of nock).The routerlicious driver can run in environments (e.g. AWS Lambda) where the execution context is frozen between invocations. A keep-alive socket pooled by the underlying fetch transport can be closed by the peer (e.g. an ALB) during the freeze; the next request reuses the dead socket and rejects with "socket hang up" / ECONNRESET / EPIPE.
request()now retries such transient network errors on a fresh socket, up to 3 attempts (1 initial + 2 retries, 250ms apart), before surfacing the error. A self-signed-certificate failure is excluded from retry since it's permanent, not transient.Reviewer Guidance
The review process is outlined on this wiki page.
The retry bound (3 attempts) and delay (250ms) were chosen empirically in the downstream fork; happy to discuss if a different value/backoff strategy is preferred. This was authored in an environment without network access to build/test locally — CI will be the first real verification.