Skip to content

fix: improve deadlock fix with forked deadlocks detection#1

Closed
raythurnvoid wants to merge 53 commits intofairbanksg:fix-ssr-hangfrom
raythurnvoid:improve_deadlock_deps_fix
Closed

fix: improve deadlock fix with forked deadlocks detection#1
raythurnvoid wants to merge 53 commits intofairbanksg:fix-ssr-hangfrom
raythurnvoid:improve_deadlock_deps_fix

Conversation

@raythurnvoid
Copy link
Copy Markdown

@raythurnvoid raythurnvoid commented Jun 22, 2021

Description

This aim to fix a particular type of circular dependency that causes tricky deadlocks, deadlocks with forked imports stack

A -> B means: B is imported by A and B has A in its stack
A ... B means: A is waiting for B to ssrLoadModule()

H -> X ... Y
H -> X -> Y ... B
H -> A ... B
H -> A -> B ... X

Forked deadlock description:

[X] is waiting for [Y] to resolve
 ↑                  ↳ is waiting for [A] to resolve
 │                                    ↳ is waiting for [B] to resolve
 │                                                      ↳ is waiting for [X] to resolve
 └────────────────────────────────────────────────────────────────────────┘

This may seems a traditional deadlock, but the thing that makes this special is the import stack of each module:

[X] stack:
	[H]
[Y] stack:
	[X]
	[H]
[A] stack:
	[H]
[B] stack:
	[A]
	[H]

Even if [X] is imported by [B], [B] is not in [X]'s stack because it's imported by [H] in first place then it's stack is only composed by [H]. [H] forks the imports stack and this make hard to be found.

Fix description

Vite, when imports [X], should check whether [X] is already pending and if it is, it must check that, when it was imported in first place, the stack of [X] doesn't have any module in common with the current module; in this case [B] has the module [H] is common with [X] and i can assume that a deadlock is going to happen.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

haoqunjiang and others added 30 commits June 8, 2021 06:25
…nerated maps (vitejs#3684)

* fix(types): add hidden to sourcemap

* docs: update sourcemap config
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Anthony Fu <[email protected]>
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.