gatsby: Production Build on Netlify/Linux produce unhandled error

This builds just fine locally both in gatsby develop and gatsby build.

But once it pulls from my git repo (and runs on Netlify), it throws this.

Gatsby 1.1.10

4:21:50 PM: success Building production JavaScript bundles — 13.303 s
4:21:55 PM: error UNHANDLED EXCEPTION
4:21:55 PM: 

  TypeError: errorStr.split is not a function
  
  - errors.js:41 createErrorFromString
    [repo]/[gatsby]/[gatsby-cli]/lib/reporter/errors.js:41:34
  
  - build-html.js:58 
    [repo]/[gatsby]/dist/commands/build-html.js:58:33
  
  - Compiler.js:194 Compiler.<anonymous>
    [repo]/[webpack]/lib/Compiler.js:194:14
  
  - Compiler.js:282 Compiler.emitRecords
    [repo]/[webpack]/lib/Compiler.js:282:37
  
  - Compiler.js:187 Compiler.<anonymous>
    [repo]/[webpack]/lib/Compiler.js:187:11
  
  - Compiler.js:275 
    [repo]/[webpack]/lib/Compiler.js:275:11
  
  - Tapable.js:60 Compiler.applyPluginsAsync
    [repo]/[tapable]/lib/Tapable.js:60:69
 
  - Compiler.js:272 Compiler.afterEmit
    [repo]/[webpack]/lib/Compiler.js:272:8
  
  - Compiler.js:267 Compiler.<anonymous>
    [repo]/[webpack]/lib/Compiler.js:267:14
  
  - async.js:52 
    [repo]/[webpack]/[async]/lib/async.js:52:16
  
  - async.js:246 done
    [repo]/[webpack]/[async]/lib/async.js:246:17
  
  - async.js:44 
    [repo]/[webpack]/[async]/lib/async.js:44:16
  
  - graceful-fs.js:43 
    [repo]/[graceful-fs]/graceful-fs.js:43:10
  
4:21:56 PM: Cached NPM modules

Is there any way I can dig into the actual unhandled error?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 37 (28 by maintainers)

Most upvoted comments

I’m unsure if this is the actual error in this specific situation, but I found that in https://github.com/gatsbyjs/gatsby/blob/6fe44fe2e4d694a84f9a2339dd0eabc4106a44f5/packages/gatsby/src/commands/build-html.js#L35 the webpackErrros[0] contains an object and isn’t a string by itself (which in turn causes split not being available on (what was expected to be a string) errorStr).

Instead, I tried appending .message to the object in build-html.js and I got error messages that could be understood again.

The line mentioned before, got changed to the following

return reject(createErrorFromString(webpackErrors[0].message, `${outputFile}.map`));

I’m not an experienced NodeJS developer, so someone might need to look more into if this is the actual issue - but it’s definitely the issue here.

As others mentioned, this was only reproducible on a Linux box; trying to import a file in all lowercase didn’t give problems locally, but Linux does care, if the actual file is written in camel case (which was the given error in my situation).

I just started getting this error today 😦 Are we close to a fix for this issue?

I have this same error just running build on my local environment.

Add this PR which should help https://github.com/gatsbyjs/gatsby/pull/2537

Will merge and push soon.

@VitaliiZhukov You should be good with ^1.9.86 for this issue now.

Bummer. Still throws for me… Anyone else have any luck?

3:39:47 PM: success Building production JavaScript bundles — 12.759 s
3:39:51 PM: error UNHANDLED EXCEPTION
3:39:51 PM: 
  TypeError: errorStr.split is not a function
  - errors.js:44 createErrorFromString
    [repo]/[gatsby-cli]/lib/reporter/errors.js:44:34
  - build-html.js:58 
    [repo]/[gatsby]/dist/commands/build-html.js:58:33
  - Compiler.js:194 Compiler.<anonymous>
    [repo]/[webpack]/lib/Compiler.js:194:14

. . .

To see the original error, add a console.log in build-html.js

Would appreciate a PR fixing up the error reporting.

@3CordGuy cool!

Hey everyone that’s hit this — just published @jquense’s fix to NPM — let us know if this fixes things for you!

@Unforgiven-wanda I haven’t had a chance to pull down the Netlify container and build against it locally to look at the error more in depth yet. Glad to know I’m not alone in this. I’ve also tried some quick fixes like reverting to specific versions of Gatsby.