Skip to content

Conversation

@novemberborn
Copy link
Member

The watcher would break if logger.finish() threw an exception. Instead rethrow this error (which causes the process to exit).

This surfaced in #1231 (comment).

The watcher would break if logger.finish() threw an exception. Instead
rethrow this error (which causes the process to exit).
@unional
Copy link

unional commented Feb 10, 2017

Tested and seems like it still hang the watch mode.

@novemberborn
Copy link
Member Author

Strange, it works for me.

  • Install npm i avajs/ava#rethrow-watch-logger-errors
  • Modify node_modules/ava/lib/code-excerpt.js to const source = fs.readFileSync(file + 'foo', 'utf8');
  • Write test file import test from 'ava'; test(t => { throw new Error("uhoh") })
  • Run AVA: ./node_modules/.bin/ava --watch test.js
 ⠼ test › [anonymous]

  1 failed/private/var/folders/_6/p8qxp_3n62zg9081tvb0lcc80000gn/T/tmp.vx8nC52ks6/node_modules/ava/lib/watcher.js:15
		throw err;
		^

Error: ENOENT: no such file or directory, open '/private/var/folders/_6/p8qxp_3n62zg9081tvb0lcc80000gn/T/tmp.vx8nC52ks6/test.jsfoo'

@unional
Copy link

unional commented Feb 10, 2017

Async test
UPDATE: my test are async, I think that makes a difference here.

@novemberborn
Copy link
Member Author

Even with import test from 'ava'; test(t => Promise.reject(new Error("uhoh"))) the watcher exits for me due to the reporter error.

@sindresorhus
Copy link
Member

sindresorhus commented Feb 14, 2017

I can confirm it correctly crashes for me too when following the above steps.

@novemberborn novemberborn merged commit 4f87059 into master Feb 14, 2017
@novemberborn novemberborn deleted the rethrow-watch-logger-errors branch February 14, 2017 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants