filamentgroup / glyphhanger

Your web font utility belt. It can subset web fonts. It can find unicode-ranges for you automatically. It makes julienne fries.
MIT License
1.11k stars 50 forks source link

UnhandledPromiseRejectionWarning #43

Closed herrbischoff closed 6 years ago

herrbischoff commented 6 years ago

Environment

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.3
BuildVersion:   17D102
$ node -v
v8.10.0
$ yarn -v
1.5.1

Issue

When running glyphhanger https://www.zachleat.com/web/, the following output is printed and nothing happens afterwards:

(node:20042) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/Users/mbischoff/.config/yarn/global/node_modules/glyphhanger/node_modules/characterset/lib/characterset.js'
(node:20042) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). (rejection id: 1)
(node:20042) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
crenshaw-dev commented 6 years ago

Similar problem with Windows 10.

(node:34500) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Evaluation failed: ReferenceError: GlyphHanger is not defined
    at <anonymous>:11:17
(node:34500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
aduh95 commented 6 years ago

Similar problem on Ubuntu:


(node:990) UnhandledPromiseRejectionWarning: Error: spawn EACCES
    at _errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:323:11)
    at Object.exports.spawn (child_process.js:502:9)
    at Function.launch (/usr/local/share/.config/yarn/global/node_modules/puppeteer/lib/Launcher.js:106:40)
    at <anonymous>
(node:990) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). (rejection id: 1)
(node:990) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
zachleat commented 6 years ago

@herrbischoff it looks like one of the dependencies wasn’t installed correctly? I don’t have too much familiarity with yarn but the characterset JS file looks like it’s missing there.

zachleat commented 6 years ago

Gonna need more info here because the test suite is passing fine and that includes tests for these use cases https://travis-ci.org/filamentgroup/glyphhanger

aduh95 commented 6 years ago

I was able to get around this issue by changing the chromium path in the puppeteer files. I guess we could solve that by exposing somehow the executablePath option of puppeteer.

Also, after thinking, I am not sure those three errors are related to the same issue since each one has a different error message.

crenshaw-dev commented 6 years ago

@aduh95 agreed, looks like UnhandledPromiseRejection basically means "something failed somewhere." (I don't know enough about Node.js to be certain.)

Reinstalling Glyphhanger and its dependencies solved the issue for me.

herrbischoff commented 6 years ago

Reinstalling did not resolve anything for me. Still the same issue, including missing characterset.js. I'm using Yarn exclusively, so I cannot check if an NPM install may work. No package has ever exhibited problems like this for me though.

@zachleat: What info do you need to troubleshoot this further?

betsu commented 6 years ago

I think the problem is perhaps from path setting. (use NPM)

missing characterset.js

Glyphhanger.js

await page.addScriptTag({
    path: path.resolve(__dirname, "../node_modules/characterset/lib/characterset.js")
});

it's looks like characterset.js must under glyphhanger. It works in global install, but not in local package install. because it's not under glyphhanger when using local package install. Instead, it's under "my project's node_modules".

maybe check characterset.js exists in path or not, then rewrite the path.

GlyphHanger is not defined error

the case is happened in local file.

WebServer.js

const SITE_PATH = path.resolve(__dirname, "..");

it should be running static server in my project folder, but runnning in glyphhanger. so, I think this code should modify to under code will be fine (tested)

const SITE_PATH = path.resolve("./");
DirtyF commented 6 years ago

First time I try to use v3, here's my debug trace when run locally on:

 $ DEBUG=glyphhanger* npx glyphhanger ./index.html
  glyphhanger WebServer.isValidUrl('./index.html') +0ms
  glyphhanger Creating static server +4ms
  glyphhanger:webserver Web server started on 8093 for /Users/frank/.nvm/versions/node/v8.10.0/lib/node_modules/glyphhanger. +0ms
  glyphhanger:webserver Transforming './index.html' to new URL 'http://localhost:8093/index.html' +1ms
  glyphhanger requesting: 'http://localhost:8093/index.html' +7ms
(node:15897) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: GlyphHanger is not defined
    at <anonymous>:11:17
    at ExecutionContext.evaluateHandle (/Users/frank/.nvm/versions/node/v8.10.0/lib/node_modules/glyphhanger/node_modules/puppeteer/lib/ExecutionContext.js:79:13)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:15897) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). (rejection id: 1)
(node:15897) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
$ DEBUG=glyphhanger* npx glyphhanger https://jamstatic.fr
  glyphhanger WebServer.isValidUrl('https://jamstatic.fr') +0ms
  glyphhanger requesting: 'https://jamstatic.fr/' +5ms
Error with https://jamstatic.fr/: Error: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (/Users/frank/.nvm/versions/node/v8.10.0/lib/node_modules/glyphhanger/node_modules/puppeteer/lib/NavigatorWatcher.js:71:21)
    at <anonymous>
1 of 1 urls failed.
  glyphhanger Closing static server +31s

Of course, it works on https://zachleat.com 😄

Nelathan commented 6 years ago

I also have the same problem. I have broken it down to a minimalistic test project: https://github.com/Schlammsuhler/glyphhanger-test

please see if it works with you.

herrbischoff commented 6 years ago

Sadly, it's pretty clear this is completely broken and not going to get fixed any time soon, if at all. I have given up on it. Therefore I will close it. If you're interested in pursuing this further, please open a new issue.