Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16748

Comment on lines +127 to +132
/**
* TODO THIS NEEDS TO ACTUALLY BE DONE
* Array of `onDestroy` callbacks that should be called at the end of the server render function
* @type {Function[]}
*/
export let async_on_destroy = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a separate async_on_destroy array? why aren't we continuing to use on_destroy exclusively, and just deferring running the callbacks until render_async is complete?

Given that we're only assigning to async_on_destroy at the start of render_async, surely if you do this...

renderAsync(Component1, ...);
renderAsync(Component2, ...);

...any onDestroy callbacks encountered in a child of Component1 after an await will be associated with Component2, unless Component2 happens to finish first and reset it? To be honest unless we're prepared to instrument every await expression I don't see a way around using AsyncLocalStorage here.

(Idle thought, we may face similar challenges around context)

@@ -44,23 +45,27 @@ export function EachBlock(node, context) {
);

if (node.fallback) {
const open = b.stmt(b.call(b.member(b.id('$$payload.out'), b.id('push')), block_open));
const open = b.stmt(b.call(b.member(b.id('$$payload'), b.id('push')), block_open));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another spot where we can make things slightly more readable/searchable

Suggested change
const open = b.stmt(b.call(b.member(b.id('$$payload'), b.id('push')), block_open));
const open = b.stmt(b.call(b.id('$$payload.push'), block_open));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants