Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Hapi to v21 #650

Merged
merged 4 commits into from
Jun 8, 2023
Merged

Update Hapi to v21 #650

merged 4 commits into from
Jun 8, 2023

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Jun 8, 2023

https://eaflood.atlassian.net/browse/WATER-4039

Phew! Somehow when looking into why there were errors during an import process we've ended up needing to upgrade Hapi!

In order to better debug issues with the NALD import process we wanted to add a new POST endpoint that would allow us to trigger it manually. But when we did we saw the request logged but nothing was actually firing. The handler would not be called and the request would not disconnect leaving Postman whirring away.

We quickly spotted GET requests were fine it was just POST failing. Hmm 🤔

Some Googling later and we found we were not alone

It seems the root cause is running Hapi on Node v16 which we are doing in our local dev environment. In our AWS environments, we're running v14 but we intend to upgrade as soon as SROC supplementary billing is shipped.

So, we know this project is fine in AWS running v14 which concurs with those posts. But we also know apps like water-abstraction-service are handling POST requests fine in our local dev environment. The difference is the version of Hapi; they are running v21 but the import service is running v18.

This change updates Hapi to v21 (and anything else needed along the way) in order to resolve this issue and get the project ready for upgrading all our environments to v16.

The upgrade from version 18->19 introduces a breaking change as per the v19 release notes hapijs/hapi#4017 - "No joi schema compiler is loaded by default and must be explicitly loaded".

This breaking change produces the error error: AssertError: Cannot set uncompiled validation rules without configuring a validator which is fixed by explicitly loading joi.

Notes

  • Bump @hapi/hapi 3 major versions
  • Fix issues caused by updating @hapi/hapi (The upgrade from version 18->19 introduces a breaking change "No joi schema compiler is loaded by default and must be explicitly loaded". This commit fixes that issue as per the v19 release notes: 19.0.0 Release Notes hapijs/hapi#4017)

https://eaflood.atlassian.net/browse/WATER-4039

Phew! Somehow when looking into why there were errors during an import process we've ended up needing to upgrade Hapi!

In order to better debug issues with the NALD import process we wanted to add a new POST endpoint that would allow us to trigger it manually. But when we did we saw the request logged but nothing was actually firing. The handler would not be called and the request would not disconnect leaving Postman whirring away.

We quickly spotted `GET` requests were fine it was just `POST` failing. Hmm 🤔

Some Googling later and we found we were not alone

- [POST request not completing on postman](https://stackoverflow.com/a/72642389/6117745)
- [Hapi js server does not respond to my post route](https://www.reddit.com/r/node/comments/syq6t0/hapi_js_server_does_not_respond_to_my_post_route/?utm_source=share&utm_medium=web2x&context=3)
- [https://github.com/hapijs/hapi/issues/4315](request disconnect event does not trigger for certain HTTP methods under node v16)

It seems the root cause is running Hapi on Node v16 which we are doing in our local dev environment. In our AWS environments we're running v14 but we intend to upgrade as soon as SROC supplementary billing is shipped.

So, we know this project is fine in AWS running v14 which concurs with those posts. But we also know apps like [water-abstraction-service](https://github.com/DEFRA/water-abstraction-service) are handling `POST` requests fine in our local dev environment. The difference is the version of Hapi; they are running v21 but the import service is running v18.

This change updates Hapi to v21 (and anything else needed along the way) in order to resolve this issue and get the project ready for upgrading all our environments to v16.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Jun 8, 2023
@Cruikshanks Cruikshanks self-assigned this Jun 8, 2023
Jozzey and others added 3 commits June 8, 2023 14:42
The upgrade from version 18->19 introduces a breaking change "No joi schema compiler is loaded by default and must be explicitly loaded". This commit fixes that issue as per the v19 release notes: hapijs/hapi#4017
@Jozzey Jozzey marked this pull request as ready for review June 8, 2023 14:51
@Jozzey
Copy link
Contributor

Jozzey commented Jun 8, 2023

@Cruikshanks I'll leave it to you check/merge as you created the PR

@Cruikshanks Cruikshanks merged commit c1ae21c into main Jun 8, 2023
@Cruikshanks Cruikshanks deleted the update-hapi branch June 8, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants