Skip to content

Commit e41596b

Browse files
authored
fix: fix multiple issues that were causing CI flakes (#1394)
1 parent 54dd058 commit e41596b

File tree

11 files changed

+28
-17
lines changed

11 files changed

+28
-17
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"temporal.replayerEntrypoint": "packages/test/src/debug-replayer.ts"
2+
"temporal.replayerEntrypoint": "packages/test/src/debug-replayer.ts",
3+
"rust-analyzer.linkedProjects": ["./packages/core-bridge/Cargo.toml"]
34
}

packages/core-bridge/Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core-bridge/scripts/build.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ function compile(requestedTarget) {
8282
const cmd = which.sync('cargo-cp-artifact');
8383

8484
console.log('Running', cmd, argv);
85-
const { status } = spawnSync(cmd, argv, {
85+
const { status, error } = spawnSync(cmd, argv, {
8686
stdio: 'inherit',
87+
shell: process.platform === 'win32',
8788
});
88-
if (status !== 0) {
89-
throw new Error(`Failed to build${target ? ' for ' + target : ''}`);
89+
if (status !== 0 || error) {
90+
throw new Error(`Failed to build${target ? ' for ' + target : ''}: status code ${status}`, error);
9091
}
9192
}
9293

packages/core-bridge/src/runtime.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{
44
cell::{Cell, RefCell},
55
collections::HashMap,
66
ops::Deref,
7+
process::Stdio,
78
sync::Arc,
89
time::{Duration, SystemTime, UNIX_EPOCH},
910
};
@@ -299,11 +300,15 @@ pub fn start_bridge_loop(
299300
callback,
300301
} => {
301302
core_runtime.tokio_handle().spawn(async move {
303+
let stdout = Stdio::from(std::io::stdout());
304+
let stderr = Stdio::from(std::io::stderr());
302305
let result = match config {
303306
EphemeralServerConfig::TestServer(config) => {
304-
config.start_server().await
307+
config.start_server_with_output(stdout, stderr).await
308+
}
309+
EphemeralServerConfig::DevServer(config) => {
310+
config.start_server_with_output(stdout, stderr).await
305311
}
306-
EphemeralServerConfig::DevServer(config) => config.start_server().await,
307312
};
308313
match result {
309314
Err(err) => {

packages/create-project/src/helpers/install.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ interface InstallArgs {
2020
* @returns A Promise that resolves once the installation is finished.
2121
*/
2222
export function install({ root, useYarn }: InstallArgs): Promise<void> {
23-
const npm = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
23+
const isWindows = process.platform === 'win32';
24+
const npm = isWindows ? 'npm.cmd' : 'npm';
2425
const command: string = useYarn ? 'yarn' : npm;
2526

2627
return spawn(command, ['install'], {
2728
cwd: root,
2829
stdio: 'inherit',
2930
env: { ...process.env, ADBLOCK: '1', DISABLE_OPENCOLLECTIVE: '1' },
31+
shell: isWindows,
3032
});
3133
}
3234

packages/test/src/helpers-integration.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from '@temporalio/worker';
2222
import * as workflow from '@temporalio/workflow';
2323
import { ConnectionInjectorInterceptor } from './activities/interceptors';
24-
import { Worker, test as anyTest, bundlerOptions } from './helpers';
24+
import { Worker, test as anyTest, bundlerOptions, registerDefaultCustomSearchAttributes } from './helpers';
2525

2626
export interface Context {
2727
env: TestWorkflowEnvironment;
@@ -59,6 +59,7 @@ export function makeTestFunction(opts: {
5959
],
6060
},
6161
});
62+
await registerDefaultCustomSearchAttributes(env.connection);
6263
const workflowBundle = await bundleWorkflowCode({
6364
...bundlerOptions,
6465
workflowInterceptorModules: [...defaultWorkflowInterceptorModules, ...(opts.workflowInterceptorModules ?? [])],

packages/test/src/test-client-connection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ test('No 10s delay on close due to grpc-js', async (t) => {
423423
}
424424
});
425425
const duration = Date.now() - startTime;
426-
t.true(duration < 2000, `Expected duration to be less than 2s, got ${duration / 1000}s`);
426+
t.true(duration < 5000, `Expected duration to be less than 5s, got ${duration / 1000}s`);
427427
} finally {
428428
server.forceShutdown();
429429
}

packages/test/src/test-integration-workflows.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ test('HistorySize is visible in WorkflowExecutionInfo', async (t) => {
153153

154154
export async function suggestedCAN(): Promise<boolean> {
155155
const maxEvents = 40_000;
156-
const batchSize = 100;
156+
const batchSize = 1000;
157157
if (workflow.workflowInfo().continueAsNewSuggested) {
158158
return false;
159159
}
160160
while (workflow.workflowInfo().historyLength < maxEvents) {
161-
await Promise.all(new Array(batchSize).fill(undefined).map((_) => workflow.sleep(1)));
161+
await Promise.all(Array.from({ length: batchSize }, (_) => workflow.sleep(1)));
162162
if (workflow.workflowInfo().continueAsNewSuggested) {
163163
return true;
164164
}

scripts/test-example.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const path = require('path');
21
const { spawn: spawnChild, spawnSync } = require('child_process');
32
const arg = require('arg');
43
const { shell, kill } = require('./utils');

scripts/utils.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class ChildProcessError extends Error {
99
}
1010
}
1111

12+
const shell = /^win/.test(process.platform);
13+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14+
1215
async function waitOnChild(child) {
1316
return new Promise((resolve, reject) => {
1417
child.on('exit', (code, signal) => {
@@ -44,10 +47,7 @@ async function kill(child, signal = 'SIGINT') {
4447
async function spawnNpx(args, opts) {
4548
const npx = /^win/.test(process.platform) ? 'npx.cmd' : 'npx';
4649
const npxArgs = ['--prefer-offline', '--timing=true', '--yes', '--', ...args];
47-
await waitOnChild(spawn(npx, npxArgs, opts));
50+
await waitOnChild(spawn(npx, npxArgs, { ...opts, shell }));
4851
}
4952

50-
const shell = /^win/.test(process.platform);
51-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
52-
5353
module.exports = { kill, spawnNpx, ChildProcessError, shell, sleep };

0 commit comments

Comments
 (0)