Next js - 404 error on css and js files

Next version

13.5
upgraded to 14 but still error persist

About the error

Getting 404 error on CSS and JS files as seen in network tab. This doesn’t always occur. On the same deploy it sometimes occur while other time it doesn’t. Before, rebuilding had done immediate fix (didn’t occur about for a day after rebuild) but now even rebuilding is not doing a immediate fix.

Why 404?

I downloaded the build directory from Netlify and I found that when the error occurs the requested file is not in the requested path (the file doesn’t exist anywhere in the build directory) BUT when it the app is working well, then the file requested is the file that is in the build directory. What is the main concern is under same build being deployed sometimes it requests the unavailable file while other time it requests the correct file.

What I found after digging in

When I visit the deploy preview URL of Netlify it works well. But for my custom domain (lets say domain.com) the CSS/JS file request sent is inconsistent.
I tried pointing the domain from domain.com to app.domain.com and test.domain.com and it worked well there too but when I repoint to domain.com it again broke.
Then, hosted the next app to my server with domain.com added and there it is working well.

So, is this Netlify caching issue under domain.com?

Steps to Reproduce

The error is inconsistent and can’t be reproduced.

@sebakthapa This sounds related to the issue discussed (and apparently fixed) in this thread:

https://answers.netlify.com/t/javascript-bundle-issues-netlify-build-breaking-several-hours-after-deployment-completes/122901

Relevant responses from Netlify are: