Skip to content

Commit

Permalink
fix: detect suspense error stream with empty error
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Dec 4, 2024
1 parent 72832bd commit db871f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/server/stream-suspense.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const suspenseRegexp = /\$RC\("(?<from>[^"]+)","(?<to>[^"]+)"\)/;
const suspenseErrorRegexp = /\$RX\("(?<from>[^"]+)",\s*"(?<to>[^"]*)",\s*"(?<error>[^"]*)"\)/;
const suspenseErrorRegexp =
/\$RX\("(?<from>[^"]+)"(?:,\s*"(?<to>[^"]*)")?(?:,\s*"(?<error>[^"]*)")?\)/;

/**
* NOTE: use with renderToPipeableStream
Expand Down Expand Up @@ -119,7 +120,7 @@ class StreamSuspense {
// detect replaces suspense ids
const { from, error } = html.match(suspenseErrorRegexp)?.groups ?? {};

if (!error || !from) {
if (!from) {
return;
}

Expand Down

0 comments on commit db871f9

Please sign in to comment.