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

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)

Comment on lines +75 to +76
// TODO this is probably actually broken
async_on_destroy.push(...ondestroy);
Copy link
Member

Choose a reason for hiding this comment

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

leaving a comment here so we don't lose track of this

Comment on lines +104 to +105
// TODO more-proper error
throw new Error('Encountered an asynchronous component while rendering synchronously');
Copy link
Member

Choose a reason for hiding this comment

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

TODO

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