mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 14:25:07 +00:00
prevent hanging with large numbers of links (#604)
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -5530,9 +5530,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"yootils": {
|
"yootils": {
|
||||||
"version": "0.0.14",
|
"version": "0.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/yootils/-/yootils-0.0.14.tgz",
|
"resolved": "github:bwbroersma/yootils#77a0949b90387af0bff8081cf596a752a1a3e08e",
|
||||||
"integrity": "sha512-yWoA/a/4aVUp5nqfqdjbTdyXcR8d0OAbRQ8Ktu3ZsfQnArwLpS81oqZl3adIszX3p8NEhT0aNHARPsaTwBH/Qw==",
|
|
||||||
"dev": true
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,9 +138,9 @@ async function _export({
|
|||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
const r = await Promise.race([
|
const r = await Promise.race([
|
||||||
fetch(url.href, {
|
q.add(() => fetch(url.href, {
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
}),
|
})),
|
||||||
timeout_deferred.promise
|
timeout_deferred.promise
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ async function _export({
|
|||||||
const url = resolve(base.href, href);
|
const url = resolve(base.href, href);
|
||||||
|
|
||||||
if (url.protocol === protocol && url.host === host) {
|
if (url.protocol === protocol && url.host === host) {
|
||||||
promise = q.add(() => handle(url));
|
promise = handle(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,15 +205,17 @@ async function _export({
|
|||||||
save(pathname, r.status, type, body);
|
save(pathname, r.status, type, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ports.wait(port)
|
try {
|
||||||
.then(() => handle(root))
|
await ports.wait(port);
|
||||||
.then(() => handle(resolve(root.href, 'service-worker-index.html')))
|
await handle(root);
|
||||||
.then(() => q.close())
|
await handle(resolve(root.href, 'service-worker-index.html'));
|
||||||
.then(() => proc.kill())
|
await q.close();
|
||||||
.catch(err => {
|
|
||||||
proc.kill();
|
proc.kill()
|
||||||
throw err;
|
} catch (err) {
|
||||||
});
|
proc.kill();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_href(attrs: string) {
|
function get_href(attrs: string) {
|
||||||
|
|||||||
12
test/apps/export/src/routes/boom/[a]/[b].svelte
Normal file
12
test/apps/export/src/routes/boom/[a]/[b].svelte
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<script context="module">
|
||||||
|
export function preload({ params }) {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let a;
|
||||||
|
export let b;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{a}/{b}</p>
|
||||||
15
test/apps/export/src/routes/boom/[a]/index.svelte
Normal file
15
test/apps/export/src/routes/boom/[a]/index.svelte
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<script context="module">
|
||||||
|
export function preload({ params }) {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let a;
|
||||||
|
|
||||||
|
const list = Array(20).fill().map((_, i) => i + 1);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each list as b}
|
||||||
|
<a href="boom/{a}/{b}">{a}/{b}</a>
|
||||||
|
{/each}
|
||||||
7
test/apps/export/src/routes/boom/index.svelte
Normal file
7
test/apps/export/src/routes/boom/index.svelte
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
const list = Array(20).fill().map((_, i) => i + 1);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each list as a}
|
||||||
|
<a href="boom/{a}">{a}</a>
|
||||||
|
{/each}
|
||||||
@@ -7,3 +7,4 @@
|
|||||||
<a href= >empty anchor #4</a>
|
<a href= >empty anchor #4</a>
|
||||||
<a href>empty anchor #5</a>
|
<a href>empty anchor #5</a>
|
||||||
<a>empty anchor #6</a>
|
<a>empty anchor #6</a>
|
||||||
|
<a href="boom">boom</a>
|
||||||
@@ -19,7 +19,15 @@ describe('export', function() {
|
|||||||
|
|
||||||
assert.ok(client_assets.length > 0);
|
assert.ok(client_assets.length > 0);
|
||||||
|
|
||||||
assert.deepEqual(non_client_assets, [
|
const boom = ['boom/index.html'];
|
||||||
|
for (let a = 1; a <= 20; a += 1) {
|
||||||
|
boom.push(`boom/${a}/index.html`);
|
||||||
|
for (let b = 1; b <= 20; b += 1) {
|
||||||
|
boom.push(`boom/${a}/${b}/index.html`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(non_client_assets.sort(), [
|
||||||
'blog.json',
|
'blog.json',
|
||||||
'blog/bar.json',
|
'blog/bar.json',
|
||||||
'blog/bar/index.html',
|
'blog/bar/index.html',
|
||||||
@@ -31,8 +39,9 @@ describe('export', function() {
|
|||||||
'global.css',
|
'global.css',
|
||||||
'index.html',
|
'index.html',
|
||||||
'service-worker-index.html',
|
'service-worker-index.html',
|
||||||
'service-worker.js'
|
'service-worker.js',
|
||||||
]);
|
...boom
|
||||||
|
].sort());
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO test timeout, basepath
|
// TODO test timeout, basepath
|
||||||
|
|||||||
Reference in New Issue
Block a user