Skip to content

Commit

Permalink
add a guard to let us know if a packager loop is likely
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Nov 16, 2023
1 parent 4c618df commit f53a466
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ export class Resolver {
// no additional fallback is available.
return resolution;
}

if (nextRequest.fromFile === request.fromFile && nextRequest.specifier === request.specifier) {
throw new Error(
'Bug Discovered! New request is not === original request but has the same fromFile and specifier. This will likely create a loop.'
);
}

if (nextRequest.isVirtual) {
// virtual requests are terminal, there is no more beforeResolve or
// fallbackResolve around them. The defaultResolve is expected to know how
Expand Down

0 comments on commit f53a466

Please sign in to comment.