vercel / vercel/ncc

Running a file that requires lighthouse breaks

Open
#290 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement package issue
Dominant language
JavaScript
Stars
9.8k
Forks
326
PR merge metrics
No merged PRs in 30d

Description

The problem
I'm attempting to run lighthouse with the @now/node builder, and I am running into a problem. Here is the src and logs of the lambda. I believe below is the simplest way to replicate the bug.

The code

// test.js
require('lighthouse')

The command
ncc run test.js

The module resolution warnings

ncc: Module directory "/~/api/node_modules/lighthouse/lighthouse-core/lib/i18n" attempted to require "intl" but could not be resolved, assuming external.
ncc: Module directory "/~/api/node_modules/ws/lib" attempted to require "utf-8-validate" but could not be resolved, assuming external.
ncc: Module directory "/~/api/node_modules/ws/lib" attempted to require "bufferutil" but could not be resolved, assuming external.

The error

...
5837kB  [2471ms] - ncc 0.15.2
Error: EBADF: bad file descriptor, fstat
    at tryStatSync (fs.js:517:13)
    at Object.fs.readFileSync (fs.js:553:3)
    at Object.282 (/node_modules/lighthouse/lighthouse-core/report/html/html-report-assets.js:16:1)
    at __webpack_require__ (/webpack:bootstrap:19:1)
    at Object.180 (/node_modules/lighthouse/lighthouse-core/report/report-generator.js:8:1)
    at __webpack_require__ (/webpack:bootstrap:19:1)
    at Object.9 (/node_modules/lighthouse/lighthouse-core/runner.js:20:1)
    at __webpack_require__ (/webpack:bootstrap:19:1)
    at Object.701 (/node_modules/lighthouse/lighthouse-core/index.js:8:1)
    at __webpack_require__ (/webpack:bootstrap:19:1)
evalmachine.<anonymous>:1
(function (exports, require, module, __filename, __dirname) { module.exports=function(t,e){"use strict";var r={};function __webpack_require__(e){if(r[e]){return r[e].exports}var n=r[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}function startup(){return __webpack_require__(610)}return startup()}({29:function(t,e,r){t.exports=glob;var n=r(66);var i=r(316);var o=r(978);var s=o.Minimatch;var a=r(831);var c=r(485).EventEmitter;var f=r(589);var u=r(393);var h=r(403);var l=r(109);var p=r(778);var d=p.alphasort;var v=p.alphasorti;var m=p.setopts;var y=p.ownProp;var b=r(200);var _=r(64);var g=p.childrenIgnored;var w=p.isIgnored;var k=r(834);function glob(t,e,r){if(typeof e==="function")r=e,e={};if(!e)e={};if(e.sync){if(r)throw new TypeError("callback provided to sync glob");return l(t,e)}return new Glob(t,e,r)}glob.sync=l;var E=glob.GlobSync=l.GlobSync;glob.glob=glob;function extend(t,e){if(e===null||typeof e!=="object"){return t

TypeError: process.off is not a function
    at ChildProcess.exit (evalmachine.<anonymous>:1:31377)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

spectrum reference

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with test.js containing require('lighthouse') and the command ncc run test.js. Trace the reported EBADF in lighthouse-core/report/html/html-report-assets.js and the subsequent process.off error, then verify that requiring lighthouse completes without these errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.