question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

undici/lib/fetch/headers.js: Unexpected token (300:44)

See original GitHub issue

Bug Description

Getting this error on serverless project.

Error: Parsing file .../test_server/node_modules/undici/lib/fetch/headers.js: Unexpected token (300:44)
      at Deps.parseDeps (.../test_server/node_modules/module-deps/index.js:519:15)
      at getDeps (.../test_server/node_modules/module-deps/index.js:447:44)
      at .../test_server/node_modules/module-deps/index.js:430:38
      at ConcatStream.<anonymous> (.../test_server/node_modules/concat-stream/index.js:37:43)
      at ConcatStream.emit (node:events:532:35)
      at ConcatStream.emit (node:domain:475:12)
      at finishMaybe (.../test_server/node_modules/readable-stream/lib/_stream_writable.js:630:14)
      at endWritable (.../test_server/node_modules/readable-stream/lib/_stream_writable.js:638:3)
      at ConcatStream.Writable.end (.../test_server/node_modules/readable-stream/lib/_stream_writable.js:594:41)
      at DuplexWrapper.onend (.../test_server/node_modules/readable-stream/lib/_stream_readable.js:577:10)
      at Object.onceWrapper (node:events:639:28)
      at DuplexWrapper.emit (node:events:532:35)
      at DuplexWrapper.emit (node:domain:475:12)
      at endReadableNT (.../test_server/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

Reproducible By

Here is an example repository for the issue: https://github.com/BRoy98/undici-serverless

Note: It happens only when serverless-plugin-optimize is being used to optimize the handlers.

Steps to reproduce:

  • Clone the repository
  • Install dependencies: yarn install
  • Invoke the function: yarn invoke

To disable the optimize plugin, uncomment #L10 on serverless.yml: https://github.com/BRoy98/undici-serverless/blob/b15fb3ad50c1a2f81d1391636bc06a1794684622/serverless.yml#L10

Expected Behavior

Should run without error.

Environment

Tested on: MacOS monterey 12.4 (21F79) and Ubuntu Latest (github actions) Node v16.14.0 and Node v14.19.3

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jimmywartingcommented, Aug 27, 2022

think that acorn/detective should be updated to support ?? will help more ppl that use ?? elsewhere that don’t just use undici

0reactions
avanellicommented, Aug 29, 2022

??= assignment converted

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How to solve error "SyntaxError: Unexpected token '?'"
This will install and use the latest Node.js v14 (14.17.4). If u want to use a different version, change nvm install 14 to...
Read more >
undici-fetch - npm
Start using undici-fetch in your project by running `npm i undici-fetch`. ... Class: Headers. Represents a WHATWG Fetch Spec Headers Class ...
Read more >
unexpected token '<', "<!doctype "... is not valid json - You.com
I have some backend Node.js that is returning query data as a JSON string. var express = ...
Read more >
@next/mdx: Versions | Openbase
Disable Image Optimization API when next.config.js has unoptimized: true : #44205 ... Upgrade undici to 5.14.0 to fix fetch redirect bug: #44133 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found