Open dmtkpv opened 1 year ago
It will cause my server code to crash, I need to write a wrapper function to use it, like:
export function safeOnServerPrefetch(fn: () => any) {
onServerPrefetch(async () => {
try {
await fn();
} catch (e) {
console.log('Running onServerPrefetch error:', e);
}
});
}
I'm experiencing this same issue. I'm actually trying to throw a custom Error from OnServerPrefetch and stop the execution of the component immediately. But it's impossible since Vue/Node will crash in a somewhat random spot even though I have try-catch on higher levels. The "random" crash place seems to be around executing: let template = await fs.readFile(path.resolve(__dirname, templateName), 'utf-8');
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
Run the script
What is expected?
The output is
An error
What is actually happening?
System Info
No response
Any additional comments?
No response