sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Identifier '$haml' has already been declared

Open florian-lefebvre opened this issue 1 year ago • 5 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/astro

SDK Version

8.34.0

Framework Version

8.34.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

Hi! I'm trying to upgrade the Astro integration from 7.119.2 to 8.34.0 (also tried from 7.119.2 to 8.0.0 and same). I've tried to create a minimal reproduction to isolate this issue, but I can't manage to reproduce the error in a brand new project. I apogolize about this, I know it sucks as a maintainer not to get a minimal repro.

So this issue is first to ask for clues to debug the error, and 2nd to provide a proper minimal reproduction after debugging. There's one related issue at #13304 for Nuxt but it seems unrelated to my setup.

The issue occurs with a minimal setup, ie. pnpm astro add @sentry/astro:

export default defineConfig({
	output: 'server',
	adapter: netlify(),
	integrations: [sentry({ dsn: process.env.SENTRY_DSN })]
})

The error goes away if I remove sentry from the integrations array.

Steps to Reproduce

  1. Start the dev server with astro dev

Expected Result

The page should load properly

Actual Result

I get the following error:

12:05:04 [ERROR] [vite] Internal server error: Identifier '$haml' has already been declared
      at compileSourceTextModule (node:internal/modules/esm/utils:339:16)
      at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:168:18)
      at callTranslator (node:internal/modules/esm/loader:428:14)
      at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:434:30)
      at async link (node:internal/modules/esm/module_job:87:21)

florian-lefebvre avatar Oct 15 '24 10:10 florian-lefebvre

Hey @florian-lefebvre, thanks for reaching out. Can you add debug: true to your Sentry config and check the logs?

chargome avatar Oct 15 '24 11:10 chargome

The error seems to occur super early, here is what I get:

➜  satquiz git:(renovate/major-sentry-javascript-monorepo) ✗ pnpm astro dev  

> [email protected] astro /home/florian/Documents/github/satquiztime/satquiz
> astro "dev"

09:07:19 [@sentry/astro] Using /home/florian/Documents/github/satquiztime/satquiz/sentry/client.ts for client init.
09:07:19 [@sentry/astro] Using /home/florian/Documents/github/satquiztime/satquiz/sentry/server.ts for server init.
09:07:19 [WARN] [config] The adapter @astrojs/netlify provides experimental support for "assets". You may experience issues or breaking changes until this feature is fully supported by the adapter.
09:07:19 [WARN] [config] The adapter @astrojs/netlify provides experimental support for "astro:env getSecret". You may experience issues or breaking changes until this feature is fully supported by the adapter.
09:07:19 [types] Generated 2ms

 astro  v4.16.3 ready in 742 ms

┃ Local    http://localhost:4321/
┃ Network  use --host to expose

09:07:20 watching for file changes...
09:07:33 [ERROR] Identifier '$haml' has already been declared
  Stack trace:
    at compileSourceTextModule (node:internal/modules/esm/utils:339:16)
    at callTranslator (node:internal/modules/esm/loader:428:14)
    at async link (node:internal/modules/esm/module_job:87:21)

The error only occurs once I open localhost:4321/

florian-lefebvre avatar Oct 16 '24 07:10 florian-lefebvre

@florian-lefebvre astro build runs successfully? Are you using any UI framework integration within astro?

chargome avatar Oct 16 '24 09:10 chargome

The project has many dependencies so many things could conflict. I guess I'll have to go little by little, disabling things until it starts working to spot the issue. Thanks anyways!

florian-lefebvre avatar Oct 17 '24 09:10 florian-lefebvre

@florian-lefebvre Keep us posted here please if you spot the culprit 🙏

chargome avatar Oct 17 '24 09:10 chargome

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar Nov 23 '24 08:11 getsantry[bot]

@chargome I managed to reproduce the issue, here is a minimal reproduction: https://stackblitz.com/edit/github-lmarqdw6?file=astro.config.mjs,src%2Fpages%2Findex.astro&on=stackblitz. TLDR:

florian-lefebvre avatar Jan 06 '25 13:01 florian-lefebvre

@florian-lefebvre Any resolution for this on your end?

dgautsch avatar Feb 07 '25 21:02 dgautsch

No I have not upgraded the sentry integration

florian-lefebvre avatar Feb 07 '25 21:02 florian-lefebvre

This should already be fixed in version 9 (which is released this week).

I fixed it for v8: https://github.com/getsentry/sentry-javascript/pull/15352 (probably released with 8.55.0)

s1gr1d avatar Feb 10 '25 08:02 s1gr1d

Awesome, can't wait to try this! Is there any way to subscribe to the release of v8.55?

florian-lefebvre avatar Feb 10 '25 10:02 florian-lefebvre

If you want you can already update to version v9 (it's released now).

You cannot subscribe but our release bot (or me) will comment on this issue once the fix is released to v8.

s1gr1d avatar Feb 10 '25 11:02 s1gr1d

Thanks @s1gr1d . My company is running an SSR app with Vue and an Express server. We utilize @sentry/node and @sentry/vue. This problem pops up for us only when running in dev mode with Vite HMR middleware. I took a look at the change above and implemented this in our init options for local dev:

registerEsmLoaderHooks: {
    exclude: [/vue/],
},

That seems to resolve our issue as well.

dgautsch avatar Feb 10 '25 13:02 dgautsch

https://github.com/getsentry/sentry-javascript/pull/15352 released with 8.55.0

s1gr1d avatar Feb 20 '25 14:02 s1gr1d