Skip to content

Commit

Permalink
Add actual values to assertion error (#9668)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjervis committed Apr 24, 2024
1 parent 71a8493 commit 3ca74f3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/core/core/src/RequestTracker.js
Expand Up @@ -19,6 +19,7 @@ import logger from '@parcel/logger';
import {type Deferred} from '@parcel/utils';

import invariant from 'assert';
import {AssertionError} from 'assert';
import nullthrows from 'nullthrows';
import path from 'path';
import {
Expand Down Expand Up @@ -353,8 +354,18 @@ export class RequestGraph extends ContentGraph<

getRequestNode(nodeId: NodeId): RequestNode {
let node = nullthrows(this.getNode(nodeId));
invariant(node.type === REQUEST);
return node;

if (node.type === REQUEST) {
return node;
}

throw new AssertionError({
message: `Expected a request node: ${
node.type
} (${typeof node.type}) does not equal ${REQUEST} (${typeof REQUEST}).`,
expected: REQUEST,
actual: node.type,
});
}

replaceSubrequests(
Expand Down

0 comments on commit 3ca74f3

Please sign in to comment.