Skip to content
Open
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
9 changes: 9 additions & 0 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ module.exports = function run(args, rawArgs) {
// stop the Local instance
if (!turboScaleSession) await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);

// SDK-6211: send the Test Observability build-stop now — polling has resolved, so
// the build has finished running on BrowserStack. builds_th.finished_at is stamped
// server-side when the collector receives this stop event, so firing it here (before
// the 5s safety wait, artifact download and HTML report generation below) keeps the
// TRA build "Duration" aligned with the test window instead of the full CLI wall-clock.
// printBuildLink no-ops on non-observability runs and is idempotent (buildStopped
// guard); the later handleSyncExit stop becomes a no-op that still honors the exit code.
await printBuildLink(true);

// waiting for 5 secs for upload to complete (as a safety measure)
await new Promise(resolve => setTimeout(resolve, 5000));

Expand Down
11 changes: 10 additions & 1 deletion bin/testObservability/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ const supportFileCleanup = () => {
exports.buildStopped = false;

exports.printBuildLink = async (shouldStopSession, exitCode = null) => {
if(!this.isTestObservabilitySession() || exports.buildStopped) return;
if(!this.isTestObservabilitySession()) return;
// SDK-6211: the build-stop may be sent early (runs.js fires it at poll-resolution, before the
// post-test 5s wait + artifact download + report generation, so builds_th.finished_at — which
// the collector stamps at stop-event receipt — reflects the test window rather than the full CLI
// wall-clock). A later call here must therefore still honor the exit code instead of returning
// silently, preserving the original failing-build exit behaviour.
if(exports.buildStopped) {
if(exitCode) process.exit(exitCode);
return;
}
exports.buildStopped = true;
try {
if(shouldStopSession) {
Expand Down
Loading