Git Product home page Git Product logo

Comments (3)

henricook avatar henricook commented on June 28, 2024

I'm about to open an MR with a proposed fix for this.

Scratch that. I realised that process.on('exit' gets called for all exits, not just SIGKILLs. The code that gets passed to this function is 0 when an OOMKill happens, which has me stumped.

from next.js.

deh-code avatar deh-code commented on June 28, 2024

Hi, any updates?
I did some research online but i couldn't find out a standard way to intercept the heap out of bound exception.

The best i came up with is a file based approach, like the following

process.on("exit", (code)=>{
        // if server directory is missing inside the build folder assume something went wrong
        if (code === 0 && !_fs.existsSync(path.resolve('.next/server/'))) {
            process.exit(1);
        }

        process.exit(code); 
    })

Still i don't know if this approach cover all the cases, i'd rather wait for a maintainer feedback.
And even though this seems to work for my case, i don't know if performing file system operations while your process is running out of heap memory is a good idea .

Also, the fact that node is killing its process with a 0 code might be more a nodejs related issue rather than a nextjs related one.

from next.js.

henricook avatar henricook commented on June 28, 2024

Thanks for your eyes @deh-code! As you might notice from my closed MR I originally thought I'd solved it with just a process.on("exit... before I realised that it also fires on success. Your twist would likely work for this specific example (although a 137 exit code might be more accurate if we're assuming this can only happen on SIGKILL) but I find that I'm still left thinking that surely, surely this must be accounted for with a language construct I don't know about. Or something somewhere is catching and disguising the error.

To that end maybe another example with just a basic node program getting OOMed and hiding the exit code in the same way would be useful.

As a (rubbish) workaround, I'm just checking for existence of this path after I do a next build in my Dockerfile at the moment

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.