-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Astro could not resolve X #9777
Comments
Hi @muuvmuuv thanks for writing in! My suspicion is that this is related to using the Cloudflare adapter. Our Astro SDK is currently not compatible with non-Node runtimes such as Cloudflare workers or Vercel's Edge runtime. We need to eventually support this but think this will take some time. Will open an issue to track this and update docs. To verify, if you, for example, switch to the Node adapter, does the build error disappear? |
Ah ok, didn't know the adapter does such things and interfer complete buidl processes but makes sense. Any idea what a workaround could look like? I will test the Node adapter later but my guess is that this works, I remember that builds worked before I installed cloudflare adapter a few month back but a lot has changed in the code base since then. |
I'm not totally sure it does either but this error really looks like it. I might be off though. It's hard to debug this without more insights but I'd recommend going bottom-up or top-down and adding/removing your |
It's not ideal but you could essentially disable server-side instrumentation for |
So, the Node adapter works, and it is definitely the Sentry/astro plugin that causes the error together with Cloudflare adapter... I put sentry.server.config.js in my project root, but that does nothing, unfortunately. I am fine with not using Sentry on server side. Maybe an option for the plugin would make it so server code isn't bundled and produces these errors? |
Yes we could add this fairly easily. Thinking of an API like this one: // astro.config.mjs
sentry({
enabled: {
client: true,
server: false,
}
// or to enable/disable completely
enabled: false // true by default
}) |
AFAIK this is caused by node imports lacking the // Do this:
import { Buffer } from 'node:buffer';
// Do not do this:
import { Buffer } from 'buffer'; That would solve it! |
@florian-lefebvre We cannot use the |
Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/7.92.0 - please give it a try |
After upgrading to Stacktrace
[sentry-vite-plugin] Info: Successfully uploaded source maps to Sentry
23:30:05 [vite] ✓ built in 24.15s
23:30:05
finalizing server assets
23:30:05 [build] Rearranging server assets...
✘ [ERROR] Could not resolve "fs"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/utils.js:1:20:
1 │ import * as fs from 'fs';
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "os"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/client.js:1:20:
1 │ import * as os from 'os';
╵ ~~~~
The package "os" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "http"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/transports/http.js:2:22:
2 │ import * as http from 'http';
│ ~~~~~~
╵ "./http"
The package "http" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "fs"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/modules.js:1:41:
1 │ import { existsSync, readFileSync } from 'fs';
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "fs"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/contextlines.js:2:25:
2 │ import { readFile } from 'fs';
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "https"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/transports/http.js:3:23:
3 │ import * as https from 'https';
╵ ~~~~~~~
The package "https" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "child_process"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/context.js:2:25:
2 │ import { execFile } from 'child_process';
╵ ~~~~~~~~~~~~~~~
The package "child_process" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "fs"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/context.js:3:34:
3 │ import { readFile, readdir } from 'fs';
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "inspector"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/local-variables/local-variables-sync.js:73:32:
73 │ const { Session } = require('inspector');
╵ ~~~~~~~~~~~
The package "inspector" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "stream"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/transports/http.js:4:25:
4 │ import { Readable } from 'stream';
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/transports/http.js:5:20:
5 │ import { URL } from 'url';
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "zlib"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/transports/http.js:6:27:
6 │ import { createGzip } from 'zlib';
╵ ~~~~~~
The package "zlib" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "http"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/spotlight.js:1:22:
1 │ import * as http from 'http';
│ ~~~~~~
╵ "./http"
The package "http" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "os"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/context.js:4:20:
4 │ import * as os from 'os';
╵ ~~~~
The package "os" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "http"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/http.js:58:31:
58 │ const httpModule = require('http');
│ ~~~~~~
╵ "./http"
The package "http" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "domain"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/async/domain.js:2:24:
2 │ import * as domain from 'domain';
│ ~~~~~~~~
╵ "./domain"
The package "domain" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "net"
node_modules/.pnpm/https-proxy-agent@5.0.1/node_modules/https-proxy-agent/dist/agent.js:15:38:
15 │ const net_1 = __importDefault(require("net"));
╵ ~~~~~
The package "net" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/spotlight.js:2:20:
2 │ import { URL } from 'url';
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "async_hooks"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/async/hooks.js:3:29:
3 │ import * as async_hooks from 'async_hooks';
╵ ~~~~~~~~~~~~~
The package "async_hooks" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/anr/index.js:2:20:
2 │ import { URL } from 'url';
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "https"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/http.js:73:34:
73 │ const httpsModule = require('https');
╵ ~~~~~~~
The package "https" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/utils/http.js:2:20:
2 │ import { URL } from 'url';
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "inspector"
node_modules/.pnpm/@sentry+node@7.92.0/node_modules/@sentry/node/esm/integrations/anr/index.js:99:30:
99 │ const inspector = require('inspector');
╵ ~~~~~~~~~~~
The package "inspector" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "tls"
node_modules/.pnpm/https-proxy-agent@5.0.1/node_modules/https-proxy-agent/dist/agent.js:16:38:
16 │ const tls_1 = __importDefault(require("tls"));
╵ ~~~~~
The package "tls" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/.pnpm/https-proxy-agent@5.0.1/node_modules/https-proxy-agent/dist/agent.js:17:38:
17 │ const url_1 = __importDefault(require("url"));
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "assert"
node_modules/.pnpm/https-proxy-agent@5.0.1/node_modules/https-proxy-agent/dist/agent.js:18:41:
18 │ const assert_1 = __importDefault(require("assert"));
╵ ~~~~~~~~
The package "assert" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "events"
node_modules/.pnpm/agent-base@6.0.2/node_modules/agent-base/dist/src/index.js:5:25:
5 │ const events_1 = require("events");
╵ ~~~~~~~~
The package "events" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
Could not resolve "domain"
Stack trace: Am I missing something? |
@F0rce Does the error persist with output: hybrid? |
@anonrig Yes, error persists using Stacktrace is exactly the same, so I did not attach it
✗ node --version
v20.10.0 |
@anonrig do you have further ideas? For now, from my PoV, we're aware that Astro+Sentry doesn't work well on CF or Vercel Edge (which is why we also only guarantee that it works on Node-based server environments). If this is easily fixable, we can further investigate but full CF worker compatibility needs to be tackled when we choose to support Astro, Sveltekit, Remix, etc on None-node runtimes. |
I'm working on it. Meanwhile, if you update your
|
@anonrig that part is already in 7.92.0 so not needed. See https://github.com/getsentry/sentry-javascript/pull/9994/files |
This works together with the latest release, thanks! I let it on you to close this because some other people seem to still have issues regarding this. |
Yes, unfortunately, the proposed changes do not work. Here's a reproduction: anonrig/yagiz.co#61. We'll be adding Cloudflare integration and E2E testing to not regress in the future. |
We released https://github.com/getsentry/sentry-javascript/releases/tag/7.93.0 with @anonrig latest changes - hopefully should fix everything! |
Actually I've been told it doesn't fix everything - sorry for false alarm! Some more fixes on the way. |
@AbhiPrasad I just updated to the latest version ( I just updated my // ...(isPreview
// ? {
// enabled: {
// server: false, // temp fix
// },
// }
// : {}), I ran my build command and everything seems to be working perfectly fine. Just for reference, this is my full vite build log (GitHub Gist). If you need more information, please let me know. I'll try to deploy now and see if cloudflare throws any weird errors, if so I'll update my comment. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/astro
SDK Version
7.85.0
Framework Version
4.0.3
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Expected Result
No build errors.
Actual Result
The text was updated successfully, but these errors were encountered: