gulpjs / undertaker

Task registry that allows composition through series/parallel methods.
MIT License
200 stars 31 forks source link

stack trace is unintelligible since error is not serialized properly #80

Closed vatula closed 6 years ago

vatula commented 6 years ago

This line: https://github.com/gulpjs/undertaker/blob/47be43fe25dcd73c797732ddea5227f242478102/lib/helpers/createExtensions.js#L65

causes my stacktrace to look like this

Error: Uncaught, unspecified "error" event. ([object Object])
    at Gulp.emit (events.js:163:17)
    at Object.error (<cut>/createExtensions.js:62:10)
    at handler (<cut>/node_modules/now-and-later/lib/map.js:46:14)
    at f (<cut>/node_modules/once/once.js:25:25)
    at f (<cut>/node_modules/once/once.js:25:25)
    at done (<cut>/node_modules/async-done/index.js:24:15)
    at _combinedTickCallback (internal/process/next_tick.js:77:11)
    at Immediate._tickDomainCallback (internal/process/next_tick.js:128:9)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)

The underlying error has being thrown with JSON.stringify method:

{ TypeError: Cannot create property 'serializeMetadata' on string 'ast'
    at new JsonSerializer (<cut>/node_modules/raml-1-parser/dist/util/jsonSerializer.js:96:44)
    at ApiImpl.BasicNodeImpl.toJSON (<cut>/node_modules/raml-1-parser/dist/parser/wrapped-ast/parserCore.js:276:20)
    at Object.stringify (native)
    at client (<cut>/buildClient.js:13:54)
    at bound (domain.js:280:14)
    at runBound (domain.js:293:12)
    at asyncRunner (<cut>/node_modules/async-done/index.js:39:18)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)
  domain: 
   Domain {
     domain: null,
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     members: [] },
  domainThrown: true }

Another underlying error that triggered the same unintelligible stack trace:

{ AssertionError: Task never defined: undefined
    at getFunction (<cut>r/node_modules/undertaker/lib/helpers/normalizeArgs.js:15:5)
    at map (<cut>/node_modules/arr-map/index.js:20:14)
    at normalizeArgs (<cut>/node_modules/undertaker/lib/helpers/normalizeArgs.js:22:10)
    at Gulp.series (<cut>/node_modules/undertaker/lib/series.js:13:14)
    at <cut>/update.js:97:39
    at next (native)
    at fulfilled (<cut>/update.js:4:58)
  name: 'AssertionError',
  actual: undefined,
  expected: true,
  operator: '==',
  message: 'Task never defined: undefined',
  generatedMessage: false }

util.inspect is what I used just before aforementioned string (createExtensions.js#L65) to get the error description. I don't know if it's a proper fix for this issue. It probably isn't. The error is displayed correctly when there is no gulp in the pipeline.

phated commented 6 years ago

I'm assuming you aren't running gulp with the CLI because it attaches an error handler for that emitted event. Your stack trace is saying that the emitted error event is uncaught (and thus has no listener). Gulp doesn't and can't support the use case of running without the CLI because the CLI does a lot of changes to the environment.