I wanted to use the openid-client npm package server-side in my Meteor app but found that it doesn’t work because the http helper package it uses (https://www.npmjs.com/package/got) misbehaves.
I have traced it down so that just a simple call in a server unit test fails when it tries to connect to localhost:443 instead of the provided host.
This was a quite interesting incompatibility that I thought I’d share a solution to because it seems like something that can happen to many.
Basically, an old version 4.x of agent-base patches the core https package in a way that isn’t compatible with changes introduced in Node 10 and this breaks the got package.
Unfortunately there are a lot of npm packages that bring in that version of agent-base via various xxx-proxy packages and many of them are not yet updated to use newer versions of agent-base.
The owners of got, meanwhile, have refused to add code that detects the incompatibility and alerts the user because “the bug is caused by someone else, just have them update the dependency”.