Error: 'fly-replay' response header was returned too many times, stopping there

I get this error when issuing a post request to the login action. Not really sure why… Ive pasted my logs below. The “Replaying: {” bit is repeated a few more times above.

I’m using Cloudflare to host DNS and I’ve got full SSL turned on. Using the SSL cert through fly.io.
Everything else seems to be working normally.

Some insight into this would be greatly appreciated :pray:

Replaying: {
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  pathname: '/login',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  method: 'POST',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  PRIMARY_REGION: 'us-east-1',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  FLY_REGION: 'ord'
2022-11-14T17:04:11Z app[9768fbc9] ord [info]}
2022-11-14T17:04:11Z app[9768fbc9] ord [info]Replaying: {
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  pathname: '/login',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  method: 'POST',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  PRIMARY_REGION: 'us-east-1',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  FLY_REGION: 'ord'
2022-11-14T17:04:11Z app[9768fbc9] ord [info]}
2022-11-14T17:04:11Z app[9768fbc9] ord [info]Replaying: {
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  pathname: '/login',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  method: 'POST',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  PRIMARY_REGION: 'us-east-1',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  FLY_REGION: 'ord'
2022-11-14T17:04:11Z app[9768fbc9] ord [info]}
2022-11-14T17:04:11Z proxy[9768fbc9] chi [error]Error: 'fly-replay' response header was returned too many times, stopping there
2022-11-14T17:04:11Z app[9768fbc9] ord [info]Replaying: {
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  pathname: '/login',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  method: 'POST',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  PRIMARY_REGION: 'us-east-1',
2022-11-14T17:04:11Z app[9768fbc9] ord [info]  FLY_REGION: 'ord'
2022-11-14T17:04:11Z app[9768fbc9] ord [info]}
2022-11-14T17:04:11Z app[9768fbc9] ord [info]GET /login?redirectTo=%2Fadmin&_data=root 200 - - 2.949 ms
2022-11-14T17:04:11Z app[9768fbc9] ord [info]GET /login?redirectTo=%2Fadmin&_data=routes%2Flogin 200 - - 1.672 ms
2022-11-14T17:04:13Z app[9768fbc9] ord [info]HEAD / 200 - - 8.966 ms
2022-11-14T17:04:13Z app[9768fbc9] ord [info]GET /healthcheck 200 - - 14.797 ms
2022-11-14T17:04:23Z app[9768fbc9] ord [info]HEAD / 200 - - 9.923 ms

There’s a limit of 10 replays a single request. This is to prevent an infinite loop.

It looks like your app is returning fly-replay headers even for replayed requests. Meaning there’s likely a bug in your app’s logic.

1 Like

I’m not familiar with fly hosting. I wonder would could be causing the fly-replay headers to happen repeatedly? I have removed all logic from my action function (i’m using remix if that helps). There is no logic happening…

Are you using one of the remix stacks? Take a look at your server.ts, it might be using fly-replay in there. For example for the blues-stack: blues-stack/server.ts at main · remix-run/blues-stack · GitHub

@DAlperin In fact I am using the remix blues stack. It’s allegedly made to run on fly.io so I’m having trouble understanding why I’m getting this error? It also seems like this type of error is quite common.

The blues stack is set up to fly-replay all non GET, OPTIONS, and HEAD requests to the PRIMARY_REGION. You have set the PRIMARY_REGION to us-east-1 which is not a fly region :). The primary region wants to be something like ord or ewr or other city codes that fly uses.

@DAlperin thats good to know. It seems as though I overlooked the importance of the PRIMARY_REGION in the readme. This seems to have solved my issue. Thanks!