fix: update Koa2 plugin to await next#339
Conversation
PR googleapis#336 fixed the Koa plugin, but didn't fix the Koa2 plugin. Fixes: googleapis#335
|
I have manually verified that errors are now correctly reported with this fix in Koa2. In particular, I used the following example code: import * as Koa from 'koa';
import {ErrorReporting} from '@google-cloud/error-reporting';
const errors = new ErrorReporting({
projectId: 'my-project',
reportMode: 'always'
});
const app = new Koa();
app.use(errors.koa2);
app.use(async ctx => {
ctx.throw(new Error('This is an error from Koa2'));
});
app.use(async ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);Issue #337 will create samples tests to automatically verify our sample code work as expected. |
Codecov Report
@@ Coverage Diff @@
## master #339 +/- ##
======================================
Coverage 96.1% 96.1%
======================================
Files 34 34
Lines 1694 1694
Branches 76 76
======================================
Hits 1628 1628
Misses 49 49
Partials 17 17Continue to review full report at Codecov.
|
|
@kjin @DominicKramer would this have been a pain to catch in test? might be worth adding a ticket just to put some testing around this case. |
|
It was mentioned above that #337 is a possible way to test behavior using samples, but it's true that it should be tested as a unit test. @DominicKramer does that sound good? |
|
@kjin @bcoe I have an issue for tracking the adding of tests at issue #337. I think samples tests would be the best approach to take because we want to verify that the plugin can be used. Testing every single aspect of the plugin separately I think would be not be worth the effort when testing how the plugin overall is used could be done. This is because, to be complete, we would need to write tests for every version of every plugin. |
PR #336 fixed the Koa plugin, but didn't fix the Koa2 plugin.
Fixes: #335