geoffrich / marvel-by-year

Site to browse Marvel Unlimited by release year.
https://marvel.geoffrich.net/
35 stars 5 forks source link

UND_ERR_CONNECT_TIMEOUT when calling /refresh #28

Open geoffrich opened 1 year ago

geoffrich commented 1 year ago

The request to refresh the cache (implemented in #10) seems to regularly fail. Not sure if bumping undici or trying node 18 would fix it. There may be some weirdness going on since we're requesting back into the site.

Could also see if waiting some time (e.g. 100ms) for the request to be dispatched would help.

At time of writing, it still succeeds enough - recent comics are shown on the site.

Jan 16, 11:00:58 AM: 574be9e6 INFO   Getting comics for 1949
Jan 16, 11:00:58 AM: 574be9e6 ERROR  Refresh error TypeError: fetch failed
    at fetch (file:///var/task/.netlify/shims.js:20554:14)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at processImmediate (node:internal/timers:437:9) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (file:///var/task/.netlify/shims.js:6979:26)
      at file:///var/task/.netlify/shims.js:6926:46
      at Immediate._onImmediate (file:///var/task/.netlify/shims.js:6967:9)
      at processImmediate (node:internal/timers:466:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Jan 16, 11:00:58 AM: 574be9e6 ERROR  Refresh error TypeError: fetch failed
    at fetch (file:///var/task/.netlify/shims.js:20554:14)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at processImmediate (node:internal/timers:437:9) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (file:///var/task/.netlify/shims.js:6979:26)
      at file:///var/task/.netlify/shims.js:6926:46
      at Immediate._onImmediate (file:///var/task/.netlify/shims.js:6967:9)
      at processImmediate (node:internal/timers:466:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Jan 16, 11:00:58 AM: 574be9e6 ERROR  Refresh error TypeError: fetch failed
    at fetch (file:///var/task/.netlify/shims.js:20554:14)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (file:///var/task/.netlify/shims.js:6979:26)
      at file:///var/task/.netlify/shims.js:6926:46
      at Immediate._onImmediate (file:///var/task/.netlify/shims.js:6967:9)
      at processImmediate (node:internal/timers:466:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Jan 16, 11:00:58 AM: 574be9e6 INFO   Total comics: 8
Jan 16, 11:00:58 AM: 574be9e6 INFO   cache checked in 0.2994936400000006
Jan 16, 11:00:58 AM: 574be9e6 INFO   retrieving 1949 page 0
Jan 16, 11:00:58 AM: 574be9e6 INFO   data for 1949 page 0 is stale, firing refresh request to https://marvel.geoffrich.net/year/1949/refresh
Jan 16, 11:00:58 AM: 574be9e6 INFO   found 1949 page 0 in redis cache
Jan 16, 11:00:58 AM: 574be9e6 INFO   elapsed 0.3023234890000895
Jan 16, 11:00:58 AM: 574be9e6 Duration: 335.94 ms   Memory Usage: 158 MB    

The code is here:

https://github.com/geoffrich/marvel-by-year/blob/2309f0ad4a080ee6f1f05e86163358de5c2b2c46/src/lib/api.ts#L44-L52

geoffrich commented 1 year ago

Another (potentially related) error:

Jan 16, 11:09:19 AM: 641700be ERROR  Refresh error TypeError: fetch failed
    at fetch (file:///var/task/.netlify/shims.js:20554:14) {
  cause: SocketError: other side closed
      at TLSSocket.onSocketEnd (file:///var/task/.netlify/shims.js:8489:24)
      at TLSSocket.emit (node:events:539:35)
      at endReadableNT (node:internal/streams/readable:1345:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '169.254.76.1',
      localPort: 34842,
      remoteAddress: '34.148.19.16',
      remotePort: 443,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 3556,
      bytesRead: 0
    }
  }
}
geoffrich commented 1 year ago

From nodejs/undici issue 1531, it seems like it could be an ipv6 config issue? Maybe something wrong with the marvel.geoffrich.net domain?

geoffrich commented 1 year ago

Clicked the big "enable ipv6" on Netlify DNS, we'll see if that fixes it (probably need to wait for changes to propagate)