Skip to content

Commit

Permalink
better error reporting in insertion function
Browse files Browse the repository at this point in the history
  • Loading branch information
lubieowoce committed Feb 11, 2024
1 parent b9aecad commit 9dcb94a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/stream/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ export const onRequest = defineMiddleware(async (ctx, next) => {

const BOOTSTRAP_SCRIPT = `<script>
window.__SIMPLE_SUSPENSE_INSERT = function (id) {
var template = document.querySelector('[data-suspense="' + id + '"]').content;
var dest = document.querySelector('[data-suspense-fallback="' + id + '"]');
dest.replaceWith(template);
}
try {
var template = document.querySelector('[data-suspense="' + id + '"]').content;
var dest = document.querySelector('[data-suspense-fallback="' + id + '"]');
dest.replaceWith(template);
} catch (e) {
console.error("Failed to insert async content (Suspense boundary id: " + id + ")", e);
}
};
</script>`;

function asyncChunkInsertionHTML(id: number, chunk: string) {
Expand Down

0 comments on commit 9dcb94a

Please sign in to comment.