Repository navigation
Server timeout: Cannot read property 'replace' of undefined #16
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Pretty simple I run the server and all works fine and dandy before it times out.
CLI:
http to https redirection active.
Server running on port 443.
Unexpected error undefined:
TypeError: Cannot read property 'replace' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build && CERT_PATH=./ssl/ serve build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-28T02_53_09_689Z-debug.log
Log:
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /usr/local/lib/node_modules/np$
9 verbose lifecycle [email protected]~build: CWD: /root/vldy.org/client
10 silly lifecycle [email protected]~build: Args: [ '-c', 'react-scripts build &&$
11 silly lifecycle [email protected]~build: Returned: code: 1 signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `react-scripts build && CERT_PAT$
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/n$
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/n$
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
14 verbose pkgid [email protected]
15 verbose cwd /root/vldy.org/client
16 verbose Linux 4.15.0-52-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.16.0
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `react-scripts build && CERT_PATH=./ssl/ serve $
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional lo$
24 verbose exit [ 1, true ]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
daquinoaldo commentedon Jul 30, 2019
Hi, thank you for reaching out to me!
I've tried to reproduce, unsuccessfully. So, for the moment I can only share some considerations with you.
1. Stange output
This is the normal log of https-localhost. A line is missing, though. These two lines are usually preceded by this one:
where
/your/static/pathisbuildin your case.Can you please check if it prints this line?
2.
replacelocation in codeSupposing is not a React error, but an error concerning https-localhost, it should be related to an object on which I call the
replacefunction that should be valid and instead is undefined.There are two
replaceinvocations: index.js row 44 and certs.js row 49.This latter is executed when the
mkcertfunction is invoked. so ingenerate(row 88), called ingetCerts(row 107) only ifCERT_PATHis not specified, so not our case. Furthermore,getCertsis called byapp.listeninindex.jsrow 22, but in the next line the app printsServer running on port 443.that is part of your log, hence thegetCertsinvocation seems to work correctly.For that reason, I suppose the problem is in
index.jsrow 44 and that the undefined object isreq.headers["host"]. Anyway, this part of code is reached only when you send a request tohttp://localhost.It is possible that you visited this page and that this error appears only after that action?
3. Truncated logs
Your logs seem to be truncated: pay attention to the
$at the end of some lines. The entire log may help in identifying the error.You can obtain it with
cat /root/.npm/_logs/2019-07-28T02_53_09_689Z-debug.log. Please don't usenanoor other code editors since they used to truncate lines.Thank you for your cooperation!
deoidh commentedon Aug 1, 2019
Could well be the problem, i'm gonna set the alias for the ENV variable to be permanent and watch for changes instead of feeding in the absolute path.
deoidh commentedon Aug 1, 2019
I was calling react-scripts and serve simultaneously so, perhaps that had a conflicting issue, got the following output by adding the ssl path as a permanent environment variable and calling serve on it's own.
Will keep you posted on the state of operatives 🙌
deoidh commentedon Aug 2, 2019
Ok so it still occurred 😢
Strange though I access the HTTP gateway for the serve multiple times and it doesn't seems to effect the functionality, even though eventually the error just emits.
Attempting to change
req.headers["host"]toreq.headers("host")for any notable effects, seems that express has changed this structure afew times. ** fail **Trying
req.connection.remoteAddressinsteadWorkaround for issue #16
Merge branch 'master' into #16-workaround
daquinoaldo commentedon Aug 2, 2019
Thank you for the complete log. Unfortunately, it is not as useful as I hope.
Anyway, it really seems related to index.js row 44:
req.headers["host"]is undefined.I've tried to reproduce again, even with a permanent environment variable, but even after many tries it still works to me. Let me know if your tries fix the bug.
Meanwhile, I've prepared a workaround in case a fix is not found. It simply looks if
req.headers["host"]is undefined and in that case just replace it with "localhost". Of course, it's not the best fix but should work if this tool is used on localhost as intended.deoidh commentedon Aug 3, 2019
Fixed by the hardcoding it as you said, thanks!
Merge pull request #17 from daquinoaldo/#16-workaround
Update to v4.1.3 after fix of #16 (PR #17)
daquinoaldo commentedon Aug 3, 2019
Published v4.1.3 on npm with the fix. Thank you!