Skip to content

Commit

Permalink
improve consistency between dev and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
vezaynk committed Nov 19, 2023
1 parent d61fc28 commit c7a9585
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/fastify-renderer/src/node/RenderBus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class RenderBus {
for (const stream of this.streams.values()) {
if (!stream.writableFinished) {
stream.end()
stream.destroy()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fastify-renderer/src/node/renderers/react/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ export async function staticRender({ mode, bus, bootProps, destination, renderBa
if (error instanceof Error) {
bus.push('error', error.message)
}
bus.endAll()
},
onAllReady() {
// onAllReady still fires if there were errors
bus.push('error', null, false)
},
})

// Send to content
renderingPipe.pipe(bus.stack('content'))
} else {
Expand Down
10 changes: 10 additions & 0 deletions packages/fastify-renderer/test/hooks/errorHeadHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default () => ({
heads: () => {
throw new Error('Hook error!')
return ''
},
tails: () => {
// throw new Error('Hook error!')
return ''
},
})
3 changes: 2 additions & 1 deletion packages/test-apps/simple-react/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const server = async () => {
],
},
},
devMode: true,
devMode: false,
hooks: [require.resolve('../../fastify-renderer/test/hooks/errorHeadHook.ts')],
})

const ImperativeApple = server.registerRenderable(require.resolve('./ImperativeApple.tsx'))
Expand Down
9 changes: 6 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"declaration": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"lib": ["ES2020"],
"lib": [
"ES2020"
],
"jsx": "react",
"noImplicitAny": false,
"skipLibCheck": true,
"isolatedModules": true
"isolatedModules": true,
"sourceMap": true
}
}
}

0 comments on commit c7a9585

Please sign in to comment.