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

TextDecoder crashes vercel dev #1084

Open
akbyrd opened this issue Jan 22, 2025 · 1 comment
Open

TextDecoder crashes vercel dev #1084

akbyrd opened this issue Jan 22, 2025 · 1 comment

Comments

@akbyrd
Copy link

akbyrd commented Jan 22, 2025

Bug Report

Current behavior

This code crashes a function using the Edge runtime

const str = JSON.stringify({})
const enc = new TextEncoder().encode(str)
const dec = new TextDecoder().decode(enc)

Additional context/screenshots
Vercel CLI 39.3.0

Error message

X [ERROR] Could not resolve "http"

    node_modules/@edge-runtime/primitives/dist/load.js:688:38:
      688 │     var { IncomingMessage } = 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.     

X [ERROR] Could not resolve "stream"

    node_modules/@edge-runtime/primitives/dist/load.js:689:25:
      689 │     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.     

X [ERROR] Could not resolve "net"

    node_modules/@edge-runtime/primitives/dist/load.js:690:22:
      690 │     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.

X [ERROR] Could not resolve "querystring"

    node_modules/@edge-runtime/primitives/dist/load.js:693:32:
      693 │     var { stringify } = 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.

X [ERROR] Could not resolve "diagnostics_channel"

    node_modules/@edge-runtime/primitives/dist/load.js:1238:37:
      1238 │     var diagnosticsChannel = require("diagnostics_channel");
           ╵                                      ~~~~~~~~~~~~~~~~~~~~~

  The package "diagnostics_channel" 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.

X [ERROR] Could not resolve "tls"

    node_modules/@edge-runtime/primitives/dist/load.js:2293:26:
      2293 │             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.

X [ERROR] Could not resolve "worker_threads"

    node_modules/@edge-runtime/primitives/dist/load.js:3404:40:
      3404 │     var { markAsUncloneable } = require("worker_threads");
           ╵                                         ~~~~~~~~~~~~~~~~

  The package "worker_threads" 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.

X [ERROR] Could not resolve "zlib"

    node_modules/@edge-runtime/primitives/dist/load.js:3824:23:
      3824 │     var 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.

X [ERROR] Could not resolve "perf_hooks"

    node_modules/@edge-runtime/primitives/dist/load.js:3828:48:
      3828 │     var { performance: performance2 } = require("perf_hooks");
           ╵                                                 ~~~~~~~~~~~~

  The package "perf_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.

X [ERROR] Could not resolve "util/types"

    node_modules/@edge-runtime/primitives/dist/load.js:3831:35:
      3831 │     var { isUint8Array } = require("util/types");
           ╵                                    ~~~~~~~~~~~~

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

X [ERROR] Could not resolve "url"

    node_modules/@edge-runtime/primitives/dist/load.js:8445:32:
      8445 │     var { URL: URL2 } = 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.

X [ERROR] Could not resolve "console"

    node_modules/@edge-runtime/primitives/dist/load.js:10993:30:
      10993 │     var { Console } = require("console");
            ╵                               ~~~~~~~~~

  The package "console" 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.

X [ERROR] Could not resolve "string_decoder"

    node_modules/@edge-runtime/primitives/dist/load.js:14494:36:
      14494 │     var { StringDecoder } = require("string_decoder");
            ╵                                     ~~~~~~~~~~~~~~~~

  The package "string_decoder" 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.

X [ERROR] Could not resolve "module"

    node_modules/@edge-runtime/primitives/dist/load.js:18585:36:
      18585 │ var import_module = __toESM(require("module"));
            ╵                                     ~~~~~~~~

  The package "module" 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.

X [ERROR] Could not resolve "stream/web"

    node_modules/@edge-runtime/primitives/dist/stream.js:33:25:
      33 │ var import_web = require("stream/web");
         ╵                          ~~~~~~~~~~~~

  The package "stream/web" 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.

Failed to compile user code for edge runtime.
Error: Build failed with 15 errors:
node_modules/@edge-runtime/primitives/dist/load.js:688:38: ERROR: Could not resolve "http"
node_modules/@edge-runtime/primitives/dist/load.js:689:25: ERROR: Could not resolve "stream"
node_modules/@edge-runtime/primitives/dist/load.js:690:22: ERROR: Could not resolve "net"
node_modules/@edge-runtime/primitives/dist/load.js:693:32: ERROR: Could not resolve "querystring"
node_modules/@edge-runtime/primitives/dist/load.js:1238:37: ERROR: Could not resolve "diagnostics_channel"
...
(node:10112) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled 
with .catch(). The promise rejected with the reason:
Error: Command failed: taskkill /pid 15264 /T /F
ERROR: The process "15264" not found.

    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at ChildProcess.exithandler (node:child_process:414:12)
    at ChildProcess.emit (node:events:524:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)
Error: An unexpected error occurred!
Error: Command failed: taskkill /pid 15264 /T /F
ERROR: The process "15264" not found.

    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at ChildProcess.exithandler (node:child_process:414:12)
    at ChildProcess.emit (node:events:524:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1101:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)

@akbyrd
Copy link
Author

akbyrd commented Jan 22, 2025

This happened because my editor added import { TextDecoder } from "@edge-runtime/primitives". Removing the explicit import prevents the crash.

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

1 participant