testdriverai 6.0.27-canary.9f60cc1.0 → 6.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agent/index.js
CHANGED
|
@@ -222,7 +222,15 @@ class TestDriverAgent extends EventEmitter2 {
|
|
|
222
222
|
if (skipPostrun) {
|
|
223
223
|
this.exit(true);
|
|
224
224
|
} else {
|
|
225
|
-
|
|
225
|
+
try {
|
|
226
|
+
await this.summarize(error.message);
|
|
227
|
+
} catch (summarizeError) {
|
|
228
|
+
// If summarization fails, log it but don't let it prevent postrun from running
|
|
229
|
+
this.emitter.emit(
|
|
230
|
+
events.log.warn,
|
|
231
|
+
theme.yellow(`Failed to summarize: ${summarizeError.message}`),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
226
234
|
// Always run postrun lifecycle script, even for fatal errors
|
|
227
235
|
return await this.exit(true, false, true);
|
|
228
236
|
}
|
package/agent/lib/commands.js
CHANGED
|
@@ -766,7 +766,12 @@ const createCommands = (
|
|
|
766
766
|
try {
|
|
767
767
|
await script.runInNewContext(context);
|
|
768
768
|
} catch (e) {
|
|
769
|
-
console.error
|
|
769
|
+
// Log the error to the emitter instead of console.error to maintain consistency
|
|
770
|
+
emitter.emit(
|
|
771
|
+
events.log.debug,
|
|
772
|
+
`JavaScript execution error: ${e.message}`,
|
|
773
|
+
);
|
|
774
|
+
// Wait a tick to allow any promise rejections to be handled
|
|
770
775
|
throw new CommandError(`Error running script: ${e.message}`);
|
|
771
776
|
}
|
|
772
777
|
|
|
@@ -124,6 +124,14 @@ class BaseCommand extends Command {
|
|
|
124
124
|
process.exit(exitCode);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
// Handle unhandled promise rejections to prevent them from interfering with the exit flow
|
|
128
|
+
// This is particularly important when JavaScript execution in VM contexts leaves dangling promises
|
|
129
|
+
process.on("unhandledRejection", (reason) => {
|
|
130
|
+
// Log the rejection but don't let it crash the process
|
|
131
|
+
console.error("Unhandled Promise Rejection:", reason);
|
|
132
|
+
// The exit flow should continue normally
|
|
133
|
+
});
|
|
134
|
+
|
|
127
135
|
// Handle show window events
|
|
128
136
|
this.agent.emitter.on("show-window", async (url) => {
|
|
129
137
|
console.log(`Live test execution: `);
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
version: 5.1.1
|
|
2
|
+
session: 67f00511acbd9ccac373edf7
|
|
3
|
+
steps:
|
|
4
|
+
- prompt: execute powershell multiline
|
|
5
|
+
commands:
|
|
6
|
+
- command: exec
|
|
7
|
+
lang: js
|
|
8
|
+
code: |
|
|
9
|
+
const failingPromise = new Promise((resolve, reject) => {
|
|
10
|
+
try {
|
|
11
|
+
// Simulate some operation that fails
|
|
12
|
+
throw new Error("Something went wrong!");
|
|
13
|
+
} catch (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Usage
|
|
19
|
+
await failingPromise()
|