Skip to content

Error messages wrong and for wrong file #5333

Closed

Description

@LukaHarambasic

What version of astro are you using?

1.6.0

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

The following bug thrown for harambasic.de/src/pages/posts/[slug].astro:4:27 gets fixed when I remove the function from harambasic.de/src/util/api/categories.ts (see LukaHarambasic/harambasic.de@2b1ab7e (ignore the formatting noise).

So a bug in harambasic.de/src/util/api/categories.ts exists but it shows that a type import is the problem.

image

Is this maybe a vite bug?

I just find it very confusing and it took me some time to figure it out.

Link to Minimal Reproducible Example

LukaHarambasic/harambasic.de@0458b1b

Participation

  • I am willing to submit a pull request for this issue.

Activity

  1. LukaHarambasic commented on Nov 8, 2022

    @LukaHarambasic
    Author

    Found the error, a type import wasn't explicit - LukaHarambasic/harambasic.de@37f51b0
    But I still think the error message is kind of strange.

  2. self-assigned this
    on Nov 8, 2022
  3. added
    feat: errors
    on Nov 8, 2022
  4. Princesseuh commented on Nov 8, 2022

    @Princesseuh
    Member

    #5316 will slightly improve the message, by adding the nuance that this is often caused by a typo, but might not be the case

    But, unfortunately the fix in that PR isn't super informative either - Vite gives a super generic error whenever it fails to import a file (which in a lot of cases, it simply a typo) so we don't have much information to go on apart that, well, the import failed

    We will soon take the following steps for this:

    • Contribute a better error message to Vite itself
    • Add an extended description in our docs (that you'll be able to go to directly from the error overlay) that list more common cases, such as this one

    Hopefully, that'll make things much clearer!

    Thank you for reporting this issue!

  5. added
    ecosystem: upstream
    on Nov 9, 2022
  6. Princesseuh commented on Nov 9, 2022

    @Princesseuh
    Member

    Here's the upstream issue to track for this: vitejs/vite#10002

  7. bluwy commented on Nov 22, 2022

    @bluwy
    Member

    Closing as vitejs/vite#10002 is fixed. It's merged into Vite 4 and will provide a similar error message to what Astro provides now.

  8. LukaHarambasic commented on Nov 22, 2022

    @LukaHarambasic
    Author

    @Princesseuh & @bluwy, thanks for being so nice and quick. You and the whole team(s) are doing an amazing job!

  9. Princesseuh commented on Nov 22, 2022

    @Princesseuh
    Member

    No problems, always happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ecosystem: upstreamfeat: errors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions