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

Crash during build with Sanity and Cloudflare adapter #4951

Closed
1 task done
st1ng7ay opened this issue Oct 3, 2022 · 6 comments
Closed
1 task done

Crash during build with Sanity and Cloudflare adapter #4951

st1ng7ay opened this issue Oct 3, 2022 · 6 comments
Labels
ecosystem: external External library doesn't work

Comments

@st1ng7ay
Copy link

st1ng7ay commented Oct 3, 2022

What version of astro are you using?

1.4.2

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

Cloudflare

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

ray@MacBook-Air astro % yarn build
yarn run v1.22.19
$ astro build
15:25:39 [build] output target: server
15:25:39 [build] deploy adapter: @astrojs/cloudflare
15:25:39 [build] Collecting build info...
15:25:39 [build] Completed in 9ms.
15:25:39 [build] Building server entrypoints...
15:25:40 [build] Completed in 532ms.

building client
Completed in 93ms.

finalizing server assets

15:25:40 [build] Rearranging server assets...
✘ [ERROR] Could not resolve "url"

node_modules/eventsource/lib/eventsource.js:1:20:
  1 │ var parse = require('url').parse
    ╵                     ~~~~~

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/eventsource/lib/eventsource.js:3:20:
  3 │ var https = 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 "http"

node_modules/eventsource/lib/eventsource.js:4:19:
  4 │ var http = require('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 "util"

node_modules/eventsource/lib/eventsource.js:5:19:
  5 │ var util = require('util')
    ╵                    ~~~~~~

The package "util" 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 "querystring"

node_modules/get-it/lib-node/request/node-request.js:4:19:
  4 │ const qs = require('querystring');
    ╵                    ~~~~~~~~~~~~~

The package "querystring" 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/get-it/lib-node/request/node-request.js:6:20:
  6 │ const url = 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 "http"

node_modules/get-it/lib-node/request/node-request.js:8:21:
  8 │ const http = require('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 "https"

node_modules/get-it/lib-node/request/node-request.js:10:22:
  10 │ const https = 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 "tty"

node_modules/get-it/node_modules/debug/src/node.js:5:18:
  5 │ var tty = require('tty');
    ╵                   ~~~~~

The package "tty" 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 "util"

node_modules/get-it/node_modules/debug/src/node.js:6:19:
  6 │ var util = require('util');
    ╵                    ~~~~~~

The package "util" 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/get-it/node_modules/debug/src/node.js:186:23:
  186 │       var fs = require('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 "util"

node_modules/through2/through2.js:2:24:
  2 │   , inherits  = require('util').inherits
    ╵                         ~~~~~~

The package "util" 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/get-it/lib-node/request/node/tunnel.js:8:20:
  8 │ const url = 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 "net"

node_modules/get-it/node_modules/debug/src/node.js:193:24:
  193 │       var net = 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 "stream"

node_modules/decompress-response/index.js:2:41:
  2 │ const {Transform, PassThrough} = require('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 "stream"

node_modules/readable-stream/readable.js:1:21:
  1 │ var Stream = require('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/get-it/lib-node/request/node/proxy.js:9:20:
  9 │ const url = 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 "url"

node_modules/follow-redirects/index.js:1:18:
  1 │ var url = 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 "zlib"

node_modules/decompress-response/index.js:3:21:
  3 │ const zlib = require('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/follow-redirects/index.js:3:19:
  3 │ var http = 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 "https"

node_modules/follow-redirects/index.js:4:20:
  4 │ var https = require("https");
    │                     ~~~~~~~
    ╵                     "./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 "stream"

node_modules/follow-redirects/index.js:5:23:
  5 │ var Writable = require("stream").Writable;
    ╵                        ~~~~~~~~

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 "assert"

node_modules/follow-redirects/index.js:6:21:
  6 │ var assert = 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 "net"

node_modules/tunnel-agent/index.js:3:18:
  3 │ var net = 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 "tty"

node_modules/debug/src/node.js:5:20:
  5 │ const tty = require('tty');
    ╵                     ~~~~~

The package "tty" 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 "util"

node_modules/debug/src/node.js:6:21:
  6 │ const util = require('util');
    ╵                      ~~~~~~

The package "util" 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 "util"

node_modules/util-deprecate/node.js:6:25:
  6 │ module.exports = require('util').deprecate;
    ╵                          ~~~~~~

The package "util" 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 "util"

node_modules/readable-stream/lib/_stream_readable.js:72:24:
  72 │ var debugUtil = require('util');
     ╵                         ~~~~~~

The package "util" 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/supports-color/index.js:2:19:
  2 │ const os = require('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 "tty"

node_modules/supports-color/index.js:3:20:
  3 │ const tty = require('tty');
    ╵                     ~~~~~

The package "tty" 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 "util"

node_modules/readable-stream/lib/internal/streams/BufferList.js:6:19:
  6 │ var util = require('util');
    ╵                    ~~~~~~

The package "util" 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/tunnel-agent/index.js:4:18:
  4 │   , tls = 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 "http"

node_modules/tunnel-agent/index.js:5:19:
  5 │   , http = require('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 "https"

node_modules/tunnel-agent/index.js:6:20:
  6 │   , https = 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 "assert"

node_modules/tunnel-agent/index.js:8:21:
  8 │   , assert = 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 "util"

node_modules/tunnel-agent/index.js:9:19:
  9 │   , util = require('util')
    ╵                    ~~~~~~

The package "util" 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/readable-stream/lib/internal/streams/stream.js:1:25:
  1 │ module.exports = require('stream');
    │                          ~~~~~~~~
    ╵                          "./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 Build failed with 37 errors:
node_modules/debug/src/node.js:5:20: ERROR: Could not resolve "tty"
node_modules/debug/src/node.js:6:21: ERROR: Could not resolve "util"
node_modules/decompress-response/index.js:2:41: ERROR: Could not resolve "stream"
node_modules/decompress-response/index.js:3:21: ERROR: Could not resolve "zlib"
node_modules/eventsource/lib/eventsource.js:1:20: ERROR: Could not resolve "url"
...
File:
node_modules/debug/src/node.js
Code:
> 5 | const tty = require('tty');
| ^
6 | const util = require('util');
8 | /**

Stacktrace:
Error: Build failed with 37 errors:
node_modules/debug/src/node.js:5:20: ERROR: Could not resolve "tty"
node_modules/debug/src/node.js:6:21: ERROR: Could not resolve "util"
node_modules/decompress-response/index.js:2:41: ERROR: Could not resolve "stream"
node_modules/decompress-response/index.js:3:21: ERROR: Could not resolve "zlib"
node_modules/eventsource/lib/eventsource.js:1:20: ERROR: Could not resolve "url"
...
at failureErrorWithLog (/Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:1624:15)
at /Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:1266:28
at runOnEndCallbacks (/Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:1179:65)
at buildResponseToResult (/Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:1264:7)
at /Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:1377:14
at /Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:678:9
at handleIncomingPacket (/Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:775:9)
at Socket.readFromStdout (/Users/ray/Code/intelmed-ts/astro/node_modules/esbuild/lib/main.js:644:7)
at Socket.emit (node:events:527:28)
at Socket.emit (node:domain:475:12)

error Command failed with exit code 1.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-cdyygj?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@arstnei0
Copy link

arstnei0 commented Oct 3, 2022

I guess #4888 is dealing with it. This problem is similar to issue #4949.

@st1ng7ay
Copy link
Author

st1ng7ay commented Oct 3, 2022

nope, it doesn't help. I don't use react at this example.
It breaks at Cloudflare adaptor with
import sanityClient from '@sanity/client';

With Netlify build fine.

@arstnei0
Copy link

arstnei0 commented Oct 3, 2022

It's the problem of the cloudflare integration.

We think that the problem is caused by the esbuild configuration. In #4888, they are still discussing it because React need a different resolution.

#4949, #4869 and #4039 all have this problem.

@arstnei0
Copy link

arstnei0 commented Oct 3, 2022

nope, it doesn't help. I don't use react at this example. It breaks at Cloudflare adaptor with import sanityClient from '@sanity/client';

With Netlify build fine.

I am not sure if I have provided a solution🤣.

The PR#4888 is a little slow. They seem to be paused(They haven't discussed it for 3 days). Maybe we can create a new PR to deal with it?

@matthewp matthewp added the ecosystem: external External library doesn't work label Oct 4, 2022
@matthewp
Copy link
Contributor

matthewp commented Oct 4, 2022

3 days is not a very long time in an open source project. It's only tuesday after all, I'm not in the Astro PRs on the weekends most of the time. I would expect that that PR will eventually be merged in.

@matthewp
Copy link
Contributor

matthewp commented Oct 6, 2022

Fixed by #4888

@matthewp matthewp closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem: external External library doesn't work
Projects
None yet
Development

No branches or pull requests

3 participants