4lejandrito / next-plausible

Simple integration for https://nextjs.org and https://plausible.io analytics
https://next-plausible.vercel.app
MIT License
558 stars 30 forks source link

withPlausibleProxy server side networking issues #126

Open lemps opened 1 month ago

lemps commented 1 month ago

We have tested plausible on our nextjs project for some time now and we've noticed a problem with it when using withPlausibleProxy

In our logs we noticed that our server often fails some requests and the page does not load properly. The request is seemingly to the BunnyCDN where https://plausible.io/js/script.js is hosted. I see two issues with this.

  1. When the request fails I would assume that the server would fail gracefully instead of logging errors and giving a 5xx response
  2. I would assume that this request is not done that often and the response would be cached within the server

Adding a log from the error we're getting:

Error: connect ETIMEDOUT 169.150.247.39:443
at createConnectionError (node:net:1648:14)
at Timeout.internalConnectMultipleTimeout (node:net:1707:38)
at listOnTimeout (node:internal/timers:583:11)
at process.processTimers (node:internal/timers:519:7) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '169.150.247.39',
  port: 443
},
Error: connect ENETUNREACH 2400:52e0:1e00::1081:1:443 - Local (:::0)
at internalConnectMultiple (node:net:1182:16)
at Timeout.internalConnectMultipleTimeout (node:net:1712:5)
at listOnTimeout (node:internal/timers:583:11)
at process.processTimers (node:internal/timers:519:7) {
  errno: -101,
  code: 'ENETUNREACH',
  syscall: 'connect',
  address: '2400:52e0:1e00::1081:1',
  port: 443
}
4lejandrito commented 1 month ago

Hi! All withPlausibleProxy does is forwarding the script request to the plausible host via nextjs rewrites. As far as I know there is no caching. If your CDN is failing the failure is expected.