Skip to content

Parcel error handling masks genuine issues #36371

@dan-kirkham

Description

@dan-kirkham

Preliminary Checks

Description

This part of the code tries to compile the gatsby-config and seemingly sense check it.

// validate that output exists and is valid
try {
delete require.cache[bundle.filePath]
require(bundle.filePath)
} catch (e) {
if (retry >= RETRY_COUNT) {

There is a problem that it disregards any errors it receives. This caused a lot of confusion where out gatsby-config.ts file was doing something like:

// caused an error (missing quote)
const pathPrefix = JSON.parse('{"foo:"bar"}');

const config: GatsbyConfig = {
  jsxRuntime: "automatic",
  pathPrefix
};

return config;

Instead of logging sensible messages, we get the dreaded: Error: EBUSY: resource busy or locked, unlink 'C:\Users\...\.cache\.parcel-cache\data.mdb'.

Reproduction Link

https://github.com/gatsbyjs/gatsby/

Steps to Reproduce

  1. Add the following to gatsby-config.ts:
// caused an error (missing quote)
const pathPrefix = JSON.parse('{"foo:"bar"}');

const config: GatsbyConfig = {
  jsxRuntime: "automatic",
  pathPrefix
};

return config;
  1. Run gatsby dev
    ...

Expected Result

A clear error message that highlights the problem better (that the gatsby-config.ts threw an error)

Actual Result

Error: EBUSY: resource busy or locked error message, which is very misleading

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 AMD Ryzen 9 5950X 16-Core Processor            
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.2.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.47)
  npmPackages:
    gatsby: ^4.19.2 => 4.19.2 
    gatsby-cypress: 2.19.0 => 2.19.0 
    gatsby-plugin-google-tagmanager: ^4.19.0 => 4.19.0 
    gatsby-plugin-image: ^2.19.0 => 2.19.0 
    gatsby-plugin-newrelic: ^2.2.2 => 2.2.2 
    gatsby-plugin-sharp: ^4.19.0 => 4.19.0 
    gatsby-plugin-sitemap: ^5.19.0 => 5.19.0 
    gatsby-plugin-styled-components: ^5.19.0 => 5.19.0 
    gatsby-plugin-webpack-bundle-analyser-v2: 1.1.27 => 1.1.27 
    gatsby-source-filesystem: ^4.19.0 => 4.19.0 
    gatsby-transformer-remark: ^5.19.0 => 5.19.0 
    gatsby-transformer-sharp: ^4.19.0 => 4.19.0

Config Flags

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.topic: TypeScriptIssues and PRs related to TS in general, public typings or gatsby-plugin-typescripttype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions