Repository navigation
feat: report DriverInitFailure when a worker cannot create its session (v8) - #405
kamal-kaur04 wants to merge 12 commits into
Conversation
When the WebDriver new-session request fails or hits connectionRetryTimeout, the WDIO runner calls the service's `after` hook without ever calling `before`. Detect that in the worker (same path for the CLI and direct flows, since only the client sees the outcome) and send one `DriverInitFailure` sdk_events record to EDS, keyed by the TestHub build uuid, with the same payload shape as the Node SDK. The send is bounded, resent only when EDS sheds it with 429/503, and never throws into the run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
✅ Good to go
Change map (generated deterministically from the diff)graph LR
subgraph nwdio_service["wdio-service"]
npackages_browserstack_service_tests_instrumentation_funnelInstrumentation_test_ts["funnelInstrumentation.test.ts<br/>~340 lines"]
npackages_browserstack_service_src_instrumentation_funnelInstrumentation_ts["funnelInstrumentation.ts<br/>~166 lines"]
npackages_browserstack_service_src_service_ts["service.ts<br/>~51 lines"]
npackages_browserstack_service_tests_service_test_ts["service.test.ts<br/>~51 lines"]
npackages_browserstack_service_src_instrumentation_performance_performance_tester_ts["performance-tester.ts<br/>~21 lines"]
npackages_browserstack_service_tests_performance_tester_test_ts["performance-tester.test.ts<br/>~21 lines"]
npackages_browserstack_service_src_constants_ts["constants.ts<br/>~8 lines"]
n_changeset_pr_405_md["pr-405.md<br/>~6 lines"]
npackages_browserstack_service_src_instrumentation_createdDay_ts["createdDay.ts<br/>~3 lines"]
end
↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately). — SDK PR Review Agent |
E2E evidence (v8) — events receivedReal BrowserStack builds of a WDIO sample with the service built from this branch; newSession forced to fail client-side (
The unpatched baseline (0 events from failing workers) and the pre-resend 503 control were run on the v10 line — see #403. After the date fix every event lands on the correct date (the first-commit rows show the day-first 🤖 Generated with Claude Code |
…_day formatter The awaited send in the worker after hook could hold teardown for about 29s (4 attempts x 5s timeout plus backoff). All attempts now share a 10s deadline: each attempt's timeout is capped at the time remaining, a backoff that would overrun it is skipped, and sending stops once it is spent. Resends stay limited to 429/503 and at most 4 attempts. formatCreatedDay moves to its own module so performance-tester can use it without an import cycle through funnelInstrumentation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
E2E evidence — follow-up on
|
| Case | Build (testhub_uuid) |
Failed workers | Expected DriverInitFailure rows |
Rows received | created_day | SDKFeaturePerformance |
|---|---|---|---|---|---|---|
| CLI flow (mocha), 2 workers failing | fftgxeqpn691rdyi1et2d7yr6fwvbj9vnc1n5hbp |
2 | 2 | 2 (one 503 → 200 on resend) | 2026-12-02 11:10:45 | 1 row, 2026-12-02 11:10:54 |
| Healthy | du8hjy8i1iztosi0donaeglwjwak9xxhj9fo5kob |
0 | 0 | 0 | — | 1 row, 2026-12-02 11:11:21 |
Worst case now bounded: 10.02 s against a local endpoint that always answers 503 or hangs (previously ~29 s). One row per failed worker, none on the healthy run, resend on 429/503 only.
🤖 Generated with Claude Code
…runcation within the byte cap Truncation now backs off to the last whole code point so the message stays valid UTF-8 and never exceeds 8000 bytes. URL userinfo and the access key and username values are masked before the message is logged or sent, and a failed send logs only the error message. The uploadEventsData test restores fsPromises.access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings addressed in
|
| Finding | Resolution |
|---|---|
performance-tester.test.ts overwrote fsPromises.access without restoring it |
Original saved and restored in the existing afterEach (vi.spyOn can't be used here: the file's node:fs/promises mock has no access key). |
| 8000-byte cap: a cut inside a multi-byte character decoded to U+FFFD and could exceed the cap | truncateToBytes backs off to the last complete code point — result is always ≤ the cap and valid UTF-8. 7 new cases with 3- and 4-byte characters at shifted offsets (5 fail on the previous code). |
errorMessage sent and debug-logged without redaction |
Scrubbed before it is logged or sent: URL userinfo → ***@, access key and username values → ***; the send catch logs only error.message. Tests cover the request body, the logger, an unchanged normal message, and a thrown error. (The message is built from hostname and retry settings only, so this is defence in depth.) |
The report relies on WDIO calling after() without before() when session creation fails — "not demonstrated" |
Demonstrated end to end, no change: with newSession forced to fail client-side, the unpatched service sent 0 events and this branch sends exactly one per failed worker, in both the CLI flow (mocha) and the direct flow (jasmine), on v10, v9 and v8 — see the E2E evidence comments on this PR and on #403 (unpatched baseline). A healthy run, where before() does run, sends none. |
E2E on 8cedd8d (real BrowserStack builds; rows received in BrowserStack's SDK events store):
| Case | Build id | Failed workers | Expected | Received | created_day | errorMessage sent |
|---|---|---|---|---|---|---|
| CLI flow (mocha), 2 workers failing | yqpwg1wp19fydukra1bqtsaeappxlvbsyrfnfevq |
2 | 2 | 2 (one 503 → 200 on resend) | 2026-12-02 14:32:05 | [DriverInitError] WebdriverIO session could not be created (hostname=hub-euw.browserstack.com, …) — unmasked, as expected |
| Healthy | ycvsiymp1shnenjincr5aefgwzojxewwaegcj0jc |
0 | 0 | 0 | — | — |
🤖 Generated with Claude Code
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
1 similar comment
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
1 similar comment
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
… coverage Cap the message before scrubbing and anchor the userinfo pass on the scheme delimiter so a long input cannot stall the failure path. Also mask Basic/Bearer values, key-style parameters, the base64 and URL-encoded credential forms, and match the username only as a whole token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
Review findings addressed in
|
| Finding | Resolution |
|---|---|
| URL-userinfo scrub regex quadratic on long unbroken strings, run on the uncapped message | Pattern is now anchored on the delimiter (/:\/\/[^\s/?#@]+@/g → ://***@), and the message is capped at 32000 bytes on a whole character before scrubbing, then capped at 8000 bytes after. All passes are linear. 100 KB adversarial input: 1730 ms → 1.9 ms (run with no ://); 7869 ms → 0.8 ms (run ending in ://x). A 100 KB timing test is added. |
| Scrub covered only userinfo + literal values; short usernames over-redacted | New passes: Basic / Bearer values (8+ chars), access_key / accessKey / key / token / password values (after = or a JSON ":"), the literal base64 of userName:accessKey, and the URL-encoded key. The username is now masked only as a whole token of 4+ characters, so a short username no longer alters hostnames. A test per pattern. |
Unit tests, build and lint pass.
E2E on adc879c (real BrowserStack builds; events received in BrowserStack's SDK events store):
| Case | Build id | Failed workers | Expected | Received | created_day | errorMessage sent |
|---|---|---|---|---|---|---|
| CLI flow (mocha), 2 workers failing | gckyaan2l3t49u0b5qrjh9v61c3k0a8rux1yqf5i |
2 | 2 | 2 | 2026-12-02 16:04:50 | [DriverInitError] WebdriverIO session could not be created (hostname=…) — unmasked, as expected |
| Healthy | zfmdgi7zt9smj7mcbwsnvuhkpt1efkp1hxhyzmzu |
0 | 0 | 0 | — | — |
🤖 Generated with Claude Code
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
…DriverInitFailure
Review findings addressed1. Both launcher paths ( The guard is still warranted: if the build id were ever missing,
Five new tests cover the owned id, the worker fallback, and each placeholder value. Full suite passes (46 files / 1205 tests); 2. New EDS endpoint and payload shape — no change needed; verified.
🤖 Generated with Claude Code |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
1 similar comment
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
|
Closing: the driver-init failure reporting will ship on the v9 and v10 lines only (#404, #403). The v8 line is not being updated with this change. 🤖 Generated with Claude Code |
What is this about?
Reports a
DriverInitFailureSDK event when a worker cannot create its WebDriver session (newSession error or client-side timeout). Until now the service emitted no driver-init failure telemetry at all, unlike the other BrowserStack SDKs.afterhook withoutbefore; the service detects that and sends one event per failed worker. Same path for the CLI/binary flow and the direct flow.DriverInitFailureshape, includingtesthub_uuid.created_dayforDriverInitFailureandSDKFeaturePerformanceis now sent asYYYY-MM-DDTHH:MM:SS.ffffff UTC. The previousen-GBstring (DD/MM/YYYYT…) was parsed month-first downstream, so events sent on days 1–12 of a month were filed under the wrong date.Related Jira task/s
N/A
Release (mandatory for every PR — required for the
ready-for-reviewlabel)Version bump: (required — tick exactly one)
Release notes type: (optional)
Release notes (customer-facing): (optional but encouraged)
SDKFeaturePerformance,DriverInitFailure) being recorded with day and month swapped on days 1–12 of the month.Release notes (internal): (required — engineer-facing; what actually changed / why)
DriverInitFailure(sdk_events) once per worker whose session creation failed, detected asafterwithoutbefore; resend on 429/503 only.created_dayin ISO UTC forDriverInitFailureandSDKFeaturePerformance(en-GB string was parsed MM/DD downstream).DriverInitFailuresend in the workerafterhook to a 10 s total deadline (each attempt capped by the time remaining; previously up to ~29 s);created_dayformatting shared fromsrc/instrumentation/createdDay.ts.Checklist
Tested end to end against BrowserStack on CLI flow (mocha) and direct flow (jasmine): a forced client-side newSession timeout on 2 workers sends 0 events before the change and exactly 2 after (one per failed worker), each delivered and stored with the correct date; healthy runs send none. Unit tests, build and lint pass.
PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.
🤖 Generated with Claude Code