Skip to content

Commit

Permalink
partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 30, 2023
1 parent bfa808f commit 1579648
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "server.js",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --force",
"build": "npm run build:client && npm run build:server",
"build:client": "vite build --outDir dist/client",
"build:server": "vite build --ssr src/entry-server.jsx --outDir dist/server"
Expand Down
4 changes: 3 additions & 1 deletion demo/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ function ssrPlugin() {
return next();
}

const { render } = await server.ssrLoadModule(
const { render, abort } = await server.ssrLoadModule(
path.resolve(__dirname, './src/entry-server')
);

setTimeout(abort, 10000);

const indexHtml = await fs.readFile(
path.resolve(__dirname, './index.html'),
'utf-8'
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ function _renderToString(
);

if (afterDiff) afterDiff(vnode);
vnode[PARENT] = undefined;
// when we are dealing with suspense we can't do this...
// vnode[PARENT] = undefined;

if (options.unmount) options.unmount(vnode);

Expand Down Expand Up @@ -394,7 +395,7 @@ function _renderToString(
}

if (afterDiff) afterDiff(vnode);
vnode[PARENT] = undefined;
//vnode[PARENT] = undefined;
if (ummountHook) ummountHook(vnode);

// Emit self-closing tag for empty void elements:
Expand Down
3 changes: 3 additions & 0 deletions src/lib/chunked.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function renderToChunks(vnode, { context, onWrite, abortSignal }) {
function handleError(error, vnode, renderChild) {
if (!error || !error.then) return;

console.log('--- IN HANDLER ---');
// walk up to the Suspense boundary
while ((vnode = vnode[PARENT])) {
let component = vnode[COMPONENT];
Expand All @@ -50,6 +51,7 @@ function handleError(error, vnode, renderChild) {
if (!vnode) return;

let root = vnode;
// TODO: we can't unset parent because of this traversal to Suspense
while (root !== null && !root.mask && root[PARENT] !== null) {
root = root[PARENT];
}
Expand All @@ -68,6 +70,7 @@ function handleError(error, vnode, renderChild) {

const promise = error.then(
() => {
console.log('resolved');
if (abortSignal && abortSignal.aborted) return;
this.onWrite(createSubtree(id, renderChild(vnode.props.children)));
},
Expand Down

0 comments on commit 1579648

Please sign in to comment.