Repository navigation
feat(run-context): record run context from the launcher and worker processes [v9] - #397
harshit-browserstack wants to merge 5 commits into
Conversation
Write typed `[run-context]` debug lines to the service log from the launcher and from each worker that connects to the CLI: Node version, allowlisted preload and inspector flag names from execArgv and NODE_OPTIONS, inspector state, and name@version of the WebdriverIO packages resolvable from the running entry script. The launcher also records maxInstances, per-capability instances, spec-file retries and framework retries, before and after the server config is applied. The launcher facts ride on SDKTestSuccessful as `runContext`, and StartBinSessionRequest.language_version carries process.version. Nothing is written or sent when disableAutoCaptureLogs is set, or when the CLI config does not carry the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WDIO starts one worker per spec file per capability, so one line per worker grew with suite size. Worker lines now carry only per-process facts (flag names, TypeScript loader, inspector state); package versions stay on the launcher line. Only the first ten workers of each capability, by the spec index in their worker id, write a line. 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
|
Process integrityThe review gate could NOT certify this run — the verdict is held at
Change map (generated deterministically from the diff)graph LR
subgraph nwdio_service["wdio-service"]
npackages_browserstack_service_src_cli_runContext_ts["⚠ runContext.ts<br/>~433 lines"]
npackages_browserstack_service_src_constants_ts["constants.ts<br/>~48 lines"]
n_changeset_pr_397_md["pr-397.md<br/>~5 lines"]
npackages_browserstack_service_src_cli_index_ts["index.ts<br/>~3 lines"]
npackages_browserstack_service_src_launcher_ts["launcher.ts<br/>~3 lines"]
npackages_browserstack_service_src_cli_grpcClient_ts["grpcClient.ts<br/>~2 lines"]
npackages_browserstack_service_src_instrumentation_funnelInstrumentation_ts["funnelInstrumentation.ts<br/>~2 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 |
|
RUN_TESTS |
|
[SDK Wdio Test] TRA build state: passed | Stability 100% — verdict: success. Passed: 58, Failed: 0, Aggregate: 58. TRA: https://observability.browserstack.com/builds/xwr9kdktiay6abgd4guddtbjzuqvbmbf6z4qf8hi |
|
🟢 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. |
What is this about?
Target:
v9(WebdriverIO 9). Ports tomain(WebdriverIO 10) andv8follow separately.This is the service half of the run-context record: non-sensitive facts about how a WebdriverIO run is set up, so BrowserStack support can reproduce a customer's setup without asking. The service records only facts that exist inside the launcher and worker processes; everything visible from outside them (host, project files,
node_moduleson disk) is recorded by the paired BrowserStack CLI change. Each side works without the other.What it records (CLI flow only: mocha and cucumber, not multiremote):
StartBinSessionRequest.language_versionfield (sent today as an empty string)processline: Node version;execArgv/NODE_OPTIONSflag names from an allowlist (anything else is only counted); TS runner; debugger attached yes/no; versions ofwebdriverio,@wdio/cli,@wdio/local-runner, the framework adapter and the service, each with the anchor it was resolved from (found_at)workersline: framework;maxInstances, per-capabilitywdio:maxInstances,maxInstancesPerCapabilityand the capability count, before and after the server config is applied (override: server_config | none);specFileRetries; mocharetries/ cucumberretryprocesslines: per-process facts only (flags, TS runner, debugger), for the first 10 workers of each capability (cid<capability>-<n>, n < 10; a spec-file retry keeps its cid), so log volume does not grow with the number of spec filesWhere it goes. Strictly additive: no new sends, RPCs, event names or proto fields.
[run-context] {json}debug lines inlogs/bstack-wdio-service.log(file only, never the console or the WDIO logger), archived by the existing log uploadrunContextproperty on the existingSDKTestSuccessfulevent, launcher only; the exit-path resend rebuilds the same event and carries it tooGuarantees:
[run-context] skipped at=<site> reason=<code>line (no message text)disableAutoCaptureLogsand it is falsy; the service optiondisableAutoCaptureLogsis not set;BROWSERSTACK_DISABLE_AUTO_CAPTURE_LOGSis nottrue(the CLI never sees that env var, so the service checks it itself)node_moduleswalks, at most 4package.jsonreads of up to 64 KB, 250 ms budget)Reviewer notes:
RUN_CONTEXTentry at the end ofsrc/constants.ts; onlySTATE_KEY, built fromSCHEMA_VERSION, stays in the module.@wdio/cliappends--import <tsx>toNODE_OPTIONSitself, so--importandts_runner: tsxshow on every run; customer-set flags are the ones beyond it.onPrepare, so an unsetmaxInstancesreads WDIO's default100(sourcewdio_config) and cannot be told apart from an explicit100.cli/cliLogger.js(same file) rather thanbstackLogger/util.ts, so the gRPC client keeps its light import graph.Symbol.for(...)slot onprocess, so a second copy of the module in the same process shares it.Sending SDK event with datadebug line prints the wholeSDKTestSuccessfulbody, so it now includesrunContext.disableAutoCaptureLogs, every service-side record stays off;language_versionis still sent and older CLIs ignore it.Related Jira task/s
N/A (tracked internally)
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)
disableAutoCaptureLogs: truein the service options to turn it off.Release notes (internal): (required — engineer-facing; what actually changed / why)
language_versionon StartBinSession,[run-context]lines inbstack-wdio-service.log(launcher process and workers lines, plus per-process lines for the first 10 workers of each capability), andrunContextonSDKTestSuccessful. Allowlisted typed values only; honoursdisableAutoCaptureLogs(CLI config, service option and env).Checklist
Unit tests:
v9); the failing set is identical to the base (empty)tsc --noEmitcleanskippedline) gave byte-identical output before and after; that check ran locally and is not part of this diffLive acceptance: the same code before the constants move passed earlier live acceptance on WebdriverIO 9 + mocha (5 runs, including a released-service control against the same CLI build).
Live build (this head, WebdriverIO 9 + mocha, Chrome latest / Windows 11, CLI flow, run under
env -iwith planted decoy secrets):Pending: build links and
[run-context]lines will be added after the live run.PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.
🤖 Generated with Claude Code