Request from Route worker to Custom Domain worker returns 522

I have a worker on a custom domain: custom.mydomain.com
And one on a custom route: another.mydomain.com/demo/*

Requests directly to custom.mydomain.com respond correctly.
Requests to another.mydomain.com/demo/something also respond correctly.

But I call, in the code of the route worker, to the custom-domain worker, it fails with 522.

Is there any way to explain and fix this?