Skip to content

Commit 06ea6c7

Browse files
committed
fix: action event double parse
1 parent 5cdee10 commit 06ea6c7

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

.changeset/chatty-cups-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@fuzdev/fuz_app': patch
3+
---
4+
5+
fix: action event double parse

src/lib/actions/action_event.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ export class ActionEvent<
126126
return this;
127127
}
128128

129+
// Input already validated in predecessor phase — skip re-parsing
130+
if (
131+
this.#data.kind === 'request_response' &&
132+
(this.#data.phase === 'receive_response' || this.#data.phase === 'send_response')
133+
) {
134+
this.#transition_step('parsed');
135+
return this;
136+
}
137+
129138
const parsed = this.spec.input.safeParse(this.#data.input);
130139
if (parsed.success) {
131140
this.#transition_step('parsed', {input: parsed.data});

src/routes/library.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@
12911291
"name": "create_action_event",
12921292
"kind": "function",
12931293
"doc_comment": "Create an action event from a spec and initial input.",
1294-
"source_line": 452,
1294+
"source_line": 461,
12951295
"type_signature": "<TMethod extends string = string>(environment: ActionEventEnvironment, spec: { method: string; initiator: \"frontend\" | \"backend\" | \"both\"; side_effects: boolean; input: ZodType<unknown, unknown, $ZodTypeInternals<...>>; ... 4 more ...; async: true; } | { ...; } | { ...; }, input: unknown, initial_phase?: \"send_request\" | ... 8 more ... | undefined): ActionEvent<...>",
12961296
"return_type": "ActionEvent<TMethod, \"send_request\" | \"receive_request\" | \"send_response\" | \"receive_response\" | \"send_error\" | \"receive_error\" | \"send\" | \"receive\" | \"execute\", \"initial\" | \"parsed\" | \"handling\" | \"handled\" | \"failed\">",
12971297
"parameters": [
@@ -1318,7 +1318,7 @@
13181318
"name": "create_action_event_from_json",
13191319
"kind": "function",
13201320
"doc_comment": "Reconstruct an action event from serialized JSON data.",
1321-
"source_line": 479,
1321+
"source_line": 488,
13221322
"type_signature": "<TMethod extends string = string>(json: ActionEventDataUnion<TMethod>, environment: ActionEventEnvironment): ActionEvent<TMethod, \"send_request\" | ... 7 more ... | \"execute\", \"initial\" | ... 3 more ... | \"failed\">",
13231323
"return_type": "ActionEvent<TMethod, \"send_request\" | \"receive_request\" | \"send_response\" | \"receive_response\" | \"send_error\" | \"receive_error\" | \"send\" | \"receive\" | \"execute\", \"initial\" | \"parsed\" | \"handling\" | \"handled\" | \"failed\">",
13241324
"parameters": [
@@ -1335,7 +1335,7 @@
13351335
{
13361336
"name": "parse_action_event",
13371337
"kind": "function",
1338-
"source_line": 493,
1338+
"source_line": 502,
13391339
"type_signature": "(raw_json: unknown, environment: ActionEventEnvironment): ActionEvent<string, \"send_request\" | \"receive_request\" | \"send_response\" | \"receive_response\" | \"send_error\" | \"receive_error\" | \"send\" | \"receive\" | \"execute\", \"initial\" | ... 3 more ... | \"failed\">",
13401340
"return_type": "ActionEvent<string, \"send_request\" | \"receive_request\" | \"send_response\" | \"receive_response\" | \"send_error\" | \"receive_error\" | \"send\" | \"receive\" | \"execute\", \"initial\" | \"parsed\" | \"handling\" | \"handled\" | \"failed\">",
13411341
"parameters": [

0 commit comments

Comments
 (0)