-
Notifications
You must be signed in to change notification settings - Fork 9
Warning on request-internal event #602
Comments
What version of hapi are you using? |
The latest version - 17.1.1 |
Do you have a small gist or anything we can reproduce it with? |
Hello, I'm refactoring a server from Hapi v8.4 (I know.... not my server!) to 17.4. The existing implementation uses a handler like so (I changed it from
and I'm getting the same error as @illustratordavid - except that it doesn't mention anything about an unhandled promise rejection. I am, however, using make promises safe, so maybe that's wrapping the error. Here's the error output I'm seeing: The only thing I could find in the Hapi docs for this was here - the block just above this anchor shows an example:
Also, I did look into where this error is being thrown - appears it's inside
@AdriVanHoudt any idea how to fix this? |
I think you need to server.events.on({ name: 'request', channels: 'error' }, ... See https://github.com/hapijs/hapi/blob/62d87f95e98da29298911b9ff33d5b1e28912917/test/request.js#L609 |
@AdriVanHoudt Awesome, thanks for the prompt response!! I think I may be missing something about what this event is and how it's generated/supposed to be used. My understanding is it's generated internally by Hapi when it makes some kind of internal request and there's an error for some reason? I still don't get the The changelog for hapi 17 does mention this, but is a little cryptic: Thanks again! |
The changelog has a detailed description of the changes. |
So the docs are outdated then? |
If they still list those events... |
@AdriVanHoudt @hueniverse I am interested in getting a better understanding of the 'channels' concept. For example, with something like: EDIT: looks like this is covered in the docs after all: https://hapijs.com/api#-servereventsoncriteria-listener. However, this mentions the following: Also, I'm not quite sure how to reconcile the suggested code snippet here: https://github.com/hapijs/hapi/blob/62d87f95e98da29298911b9ff33d5b1e28912917/test/request.js#L609 with the previous version of my code (also shown in the v17.4 docs):
I just visited the docs again and saw that in v17.5 there are no longer any references to |
I fixed the documentation. It will go live when the new version is published. |
I'm trying to resolve why my state is failing using the code in Hapi 17
server.events.on('request-internal', (request, event, tags) => { if (tags.error && tags.state) { if (event.message == "Cannot read property 'state' of undefined") { console.error('state is undefined', tags) } } })
This doesn't produce anything and I get the warnings
(node:22137) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): AssertionError [ERR_ASSERTION]: Unknown event request-internal warning.js:18
(node:22137) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Has anyone else seen this?
The text was updated successfully, but these errors were encountered: