Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: Invariant failed #202

Open
dylan-jaris opened this issue Aug 21, 2024 · 3 comments
Open

Uncaught Error: Invariant failed #202

dylan-jaris opened this issue Aug 21, 2024 · 3 comments

Comments

@dylan-jaris
Copy link

In our remix-vite project, we use GH actions to run a few steps during the build process. Specifically during a testing step, which uses playwright, we're seeing this error: Uncaught Error: Invariant failed. But when viewing tiny-invariant.ts I'm seeing that the error messages are stripped when in production mode so how am I supposed to be able to tell which invariant is throwing this error? When I run the tests locally I'm not seeing any invariant errors - only during the build towards production. Is there a way to enable these messages in production?

deps:

"tiny-invariant": "^1.3.3"
"@playwright/test": "1.46.1",
"@remix-run/node": "^2.11.2",
"@remix-run/react": "^2.11.2",
"@remix-run/serve": "^2.11.2"
@jaxxreal
Copy link

I came across exactly the same issue with not seeing errors on production 🤦 Ended up copying-pasting the code with stripped out portion https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts#L34

@drichardcarl
Copy link

drichardcarl commented Sep 23, 2024

You can try building source maps too or enabling source map support for remix (if using custom server).

image

@Thanaen
Copy link

Thanaen commented Oct 23, 2024

Here goes the tiny-tiny-invariant

// invariant.ts
/**
 * Check that the value is truthy, otherwise throw an error with the message
 * @param value The value to check
 * @param message The error message
 */
export function invariant(value: unknown, message: string): asserts value {
  if (value) {
    return;
  }

  throw Error(message);
}

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

No branches or pull requests

4 participants