[fix] handle promise rejections for {#await} in SSR (#6790)

pull/6796/head
Conduitry 4 years ago committed by GitHub
parent e82cf3f6d7
commit 10ce5c95fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
node-version: [8, 10, 12, 14]
node-version: [8, 10, 12, 14, 16]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1

@ -13,7 +13,10 @@ export default function(node: AwaitBlock, renderer: Renderer, options: RenderOpt
renderer.add_expression(x`
function(__value) {
if (@is_promise(__value)) return ${pending};
if (@is_promise(__value)) {
__value.then(null, @noop);
return ${pending};
}
return (function(${node.then_node ? node.then_node : ''}) { return ${then}; }(__value));
}(${node.expression.node})
`);

@ -52,6 +52,7 @@ describe('hydration', () => {
const cwd = path.resolve(`${__dirname}/samples/${dir}`);
compileOptions = config.compileOptions || {};
compileOptions.accessors = 'accessors' in config ? config.accessors : true;
const window = env();

@ -1,9 +1,9 @@
<script>
let clicked;
export let clicked;
</script>
<button on:click='{() => clicked = true}'>click me</button>
{#if clicked}
<p>clicked!</p>
{/if}
{/if}

@ -25,12 +25,13 @@ let compile = null;
const sveltePath = process.cwd().split('\\').join('/');
let unhandled_rejection = false;
process.on('unhandledRejection', err => {
function unhandledRejection_handler(err) {
unhandled_rejection = err;
});
}
describe('runtime', () => {
before(() => {
process.on('unhandledRejection', unhandledRejection_handler);
svelte = loadSvelte(false);
svelte$ = loadSvelte(true);
@ -46,6 +47,7 @@ describe('runtime', () => {
return setupHtmlEqual();
});
after(() => process.removeListener('unhandledRejection', unhandledRejection_handler));
const failed = new Set();

Loading…
Cancel
Save