I'm getting an error when building my react project using react-snaps.
I've looked around and all the errors are related to puppeteer - but I'm not using puppeteer to fetch content directly like those questions so the answers don't apply.
The issue - I think - is that when react-snap is rendering my pages, they are making API calls to my server, and some of those fail because they are not authenticated or something else. But all the other questions shows this has to do with the "page exiting before its finished" and I don't know what that means when I'm running the react-snap script? Its not fetching pages like what puppeteer is used for. (maybe it is? I don't know, never used puppeteer)
Here is my scripts:
"start": "react-scripts start",
"build": "react-scripts --max_old_space_size=4096 build && npm run build-sw && npm run clean-cra-sw",
"clean-cra-sw": "rm -f build/precache-manifest.*.js && rm -f build/service-worker.js",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build-sw": "node ./src/sw-build.js",
"postbuild": "react-snap"
Here is the errors in the debug log from "npm run build"
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Spader\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@6.10.2
3 info using node@v10.15.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle appv2.0@0.1.0~prebuild: appv2.0@0.1.0
6 info lifecycle appv2.0@0.1.0~build: appv2.0@0.1.0
7 verbose lifecycle appv2.0@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle appv2.0@0.1.0~build: PATH: C:\user...\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\user...\coding\path/to/app\node_modules\.bin;C:\user...\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\user...\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\nodejs;C:\Program Files\Amazon\AWSCLI\bin;C:\Program Files\Git\cmd;C:\Program Files\PuTTY;C:\Program Files\dotnet;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\user...\.windows-build-tools\python27;C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\user...\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\user...\AppData\Roaming\npm\node_modules\.bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\nodejs;C:\Program Files\Amazon\AWSCLI\bin;C:\Program Files\Git\cmd;C:\user...\AppData\Local\Microsoft\WindowsApps;C:\user...\AppData\Roaming\npm;C:\user...\AppData\Local\Programs\Microsoft VS Code\bin;C:\user...\.dotnet\tools;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle appv2.0@0.1.0~build: CWD: C:\user...\coding\path/to/app
10 silly lifecycle appv2.0@0.1.0~build: Args: [ '/d /s /c',
10 silly lifecycle 'react-scripts --max_old_space_size=4096 build && npm run build-sw && npm run clean-cra-sw' ]
11 silly lifecycle appv2.0@0.1.0~build: Returned: code: 0 signal: null
12 info lifecycle appv2.0@0.1.0~postbuild: appv2.0@0.1.0
13 verbose lifecycle appv2.0@0.1.0~postbuild: unsafe-perm in lifecycle true
14 verbose lifecycle appv2.0@0.1.0~postbuild: PATH: C:\user...\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\user...\coding\path/to/app\node_modules\.bin;C:\user...\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\user...\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\nodejs;C:\Program Files\Amazon\AWSCLI\bin;C:\Program Files\Git\cmd;C:\Program Files\PuTTY;C:\Program Files\dotnet;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\user...\.windows-build-tools\python27;C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\user...\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\user...\AppData\Roaming\npm\node_modules\.bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\nodejs;C:\Program Files\Amazon\AWSCLI\bin;C:\Program Files\Git\cmd;C:\user...\AppData\Local\Microsoft\WindowsApps;C:\user...\AppData\Roaming\npm;C:\user...\AppData\Local\Programs\Microsoft VS Code\bin;C:\user...\.dotnet\tools;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
15 verbose lifecycle appv2.0@0.1.0~postbuild: CWD: C:\user...\coding\path/to/app
16 silly lifecycle appv2.0@0.1.0~postbuild: Args: [ '/d /s /c', 'react-snap' ]
17 silly lifecycle appv2.0@0.1.0~postbuild: Returned: code: 1 signal: null
18 info lifecycle appv2.0@0.1.0~postbuild: Failed to exec postbuild script
19 verbose stack Error: appv2.0@0.1.0 postbuild: `react-snap`
19 verbose stack Exit status 1
19 verbose stack at EventEmitter.<anonymous> (C:\user...\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:326:16)
19 verbose stack at EventEmitter.emit (events.js:189:13)
19 verbose stack at ChildProcess.<anonymous> (C:\user...\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
19 verbose stack at ChildProcess.emit (events.js:189:13)
19 verbose stack at maybeClose (internal/child_process.js:970:16)
19 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
20 verbose pkgid appv2.0@0.1.0
21 verbose cwd C:\user...\coding\path/to/app
22 verbose Windows_NT 10.0.18362
23 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
24 verbose node v10.15.3
25 verbose npm v6.10.2
26 error code ELIFECYCLE
27 error errno 1
28 error appv2.0@0.1.0 postbuild: `react-snap`
28 error Exit status 1
29 error Failed at the appv2.0@0.1.0 postbuild script.
29 error This is probably not a problem with npm. There is likely additional logging output above.
30 verbose exit [ 1, true ]
And here is the specific error in the console when building
console.log at /ads_page: %c next state color: #4CAF50; font-weight: bold JSHandle@object
console.log at /ads_page: console.groupEnd
console.log at /ads_page: { total: { value: 0, relation: 'eq' },
max_score: null,
hits: [] }
console.log at /404.html: %c action %cFETCH_ADS_SUCCESS %c@ 11:22:01.228 color: gray; font-weight: lighter; color: inherit; color: gray; font-weight: lighter;
console.log at /404.html: %c prev state color: #9E9E9E; font-weight: bold JSHandle@object
console.log at /404.html: %c action color: #03A9F4; font-weight: bold JSHandle@object
console.log at /404.html: %c next state color: #4CAF50; font-weight: bold JSHandle@object
console.log at /404.html: console.groupEnd
console.log at /404.html: { total: { value: 0, relation: 'eq' },
max_score: null,
hits: [] }
UnhandledPromiseRejectionWarning { Error: Protocol error (Network.getResponseBody): Target closed.
at Promise (C:\path\to\app\node_modules\puppeteer\lib\Connection.js:183:56)
at new Promise (<anonymous>)
at CDPSession.send (C:\path\to\app\node_modules\puppeteer\lib\Connection.js:182:12)
at _contentPromise._bodyLoadedPromise.then (C:\path\to\app\node_modules\puppeteer\lib\NetworkManager.js:612:45)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at Response.<anonymous> (C:\path\to\app\node_modules\puppeteer\lib\helper.js:111:15)
at Page.page.on.response (C:\path\to\app\node_modules\minimalcss\src\run.js:264:20)
at Page.emit (events.js:189:13)
at NetworkManager.Page.networkManager.on.event (C:\path\to\app\node_modules\puppeteer\lib\Page.js:111:69)
at NetworkManager.emit (events.js:189:13)
at NetworkManager._onResponseReceived (C:\path\to\app\node_modules\puppeteer\lib\NetworkManager.js:272:10)
at CDPSession.emit (events.js:189:13)
at CDPSession._onMessage (C:\path\to\app\node_modules\puppeteer\lib\Connection.js:200:12)
at Connection._onMessage (C:\path\to\app\node_modules\puppeteer\lib\Connection.js:112:17)
at WebSocketTransport._ws.addEventListener.event (C:\path\to\app\node_modules\puppeteer\lib\WebSocketTransport.js:44:24)
message: 'Protocol error (Network.getResponseBody): Target closed.' }
You can see its finished fetching ads from "FETCH_ADS_SUCCESS" but then it throws this error.
Also why does it say the page is 404.html
- when there is no 404 page and it was just on the ads_page