Skip to content

Commit 54e7aa4

Browse files
authored
Merge branch 'main' into fix/security-remix-upgrade
2 parents 5b853a8 + 5fb9cc3 commit 54e7aa4

File tree

5 files changed

+99
-76
lines changed

5 files changed

+99
-76
lines changed

.changeset/calm-hooks-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/react-hooks": patch
3+
---
4+
5+
Fix `onComplete` callback firing prematurely when the realtime stream disconnects before the run finishes.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@
9494
"axios@1.9.0": ">=1.12.0",
9595
"js-yaml@>=3.0.0 <3.14.2": "3.14.2",
9696
"js-yaml@>=4.0.0 <4.1.1": "4.1.1",
97-
"jws@<3.2.3": "3.2.3"
97+
"jws@<3.2.3": "3.2.3",
98+
"qs@>=6.0.0 <6.14.1": "6.14.1",
99+
"systeminformation@>=5.0.0 <5.27.14": "5.27.14",
100+
"lodash@>=4.0.0 <4.17.23": "4.17.23"
98101
},
99102
"onlyBuiltDependencies": [
100103
"@depot/cli",

packages/cli-v3/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"dependencies": {
8484
"@clack/prompts": "0.11.0",
8585
"@depot/cli": "0.0.1-cli.2.80.0",
86-
"@modelcontextprotocol/sdk": "^1.24.0",
86+
"@modelcontextprotocol/sdk": "^1.25.2",
8787
"@opentelemetry/api": "1.9.0",
8888
"@opentelemetry/api-logs": "0.203.0",
8989
"@opentelemetry/exporter-trace-otlp-http": "0.203.0",
@@ -138,7 +138,7 @@
138138
"std-env": "^3.7.0",
139139
"strip-ansi": "^7.1.0",
140140
"supports-color": "^10.0.0",
141-
"tar": "^7.4.3",
141+
"tar": "^7.5.4",
142142
"tiny-invariant": "^1.2.0",
143143
"tinyexec": "^0.3.1",
144144
"tinyglobby": "^0.2.10",

packages/react-hooks/src/hooks/useRealtime.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ export function useRealtimeRun<TTask extends AnyTask>(
149149
const hasCalledOnCompleteRef = useRef(false);
150150

151151
// Effect to handle onComplete callback
152+
// Only call onComplete when the run has actually finished (has finishedAt),
153+
// not just when the subscription stream ends (which can happen due to network issues)
152154
useEffect(() => {
153-
if (isComplete && run && options?.onComplete && !hasCalledOnCompleteRef.current) {
155+
if (isComplete && run?.finishedAt && options?.onComplete && !hasCalledOnCompleteRef.current) {
154156
options.onComplete(run, error);
155157
hasCalledOnCompleteRef.current = true;
156158
}
@@ -313,8 +315,10 @@ export function useRealtimeRunWithStreams<
313315
const hasCalledOnCompleteRef = useRef(false);
314316

315317
// Effect to handle onComplete callback
318+
// Only call onComplete when the run has actually finished (has finishedAt),
319+
// not just when the subscription stream ends (which can happen due to network issues)
316320
useEffect(() => {
317-
if (isComplete && run && options?.onComplete && !hasCalledOnCompleteRef.current) {
321+
if (isComplete && run?.finishedAt && options?.onComplete && !hasCalledOnCompleteRef.current) {
318322
options.onComplete(run, error);
319323
hasCalledOnCompleteRef.current = true;
320324
}

0 commit comments

Comments
 (0)