GithubHelp home page GithubHelp logo

For some database schemas, PgIntrospectionPlugin.js abruptly crashes NodeJS (with --track-heap-objects flag, or memory profiling) about graphile-engine HOT 5 CLOSED

Venryx avatar Venryx commented on June 2, 2024
For some database schemas, PgIntrospectionPlugin.js abruptly crashes NodeJS (with --track-heap-objects flag, or memory profiling)

from graphile-engine.

Comments (5)

Venryx avatar Venryx commented on June 2, 2024 1

I just tested it, and yes, that unrolled version also resolves the crash. :) (And yeah, it definitely seems like a better fix, since it avoids the redundant function declaration.)

On my end, I'm still waiting for the NodeJS dev team to see what they have to say on the crash. (ie. whether they plan to fix it, or if it's enough of an edge-case that it's deprioritized/forgotten-about)

from graphile-engine.

Venryx avatar Venryx commented on June 2, 2024

Closing the issue, since I'm assuming the NodeJS team will fix the root problem. (if not, it can be re-opened)

from graphile-engine.

Venryx avatar Venryx commented on June 2, 2024

I have found a workaround for the bug for now, involving a slight refactor of the deepClone function. See here for details: nodejs/node#41539 (comment)

If the NodeJS devs take too long to fix the root problem, it may be worth creating a pull-request including the slight fix/refactor, since the bug occurs "in the wild" for some schemas supplied to Postgraphile. (and the crash is very hard to debug for people if they don't already know the cause)

from graphile-engine.

benjie avatar benjie commented on June 2, 2024

I can easily imagine wanting to refactor the workaround to be the non-workaround'd code to avoid the extra function declaration... Maybe we could refactor to use a loop instead - does that still resolve the issue?

const deepClone = value=>{
	if (Array.isArray(value)) {
		const l = value.length;
		const cloned = new Array(l);
		for (let i = 0; i < l; i++) {
			cloned[i] = deepClone(value[i]);
		}
		return cloned;
	}
	if (typeof value === "object" && value) {
		// Unrolled `reduce` to work around memory bug in Node.js
		const cloned = Object.create(null);
		const keys = Object.keys(value);
		for (let i = 0, l = keys.length; i < l; i++) {
			const k = keys[i];
			cloned[k] = deepClone(value[k]);
		}
        return cloned;
	}
	return value;
};

from graphile-engine.

benjie avatar benjie commented on June 2, 2024

I'm going to close this again, because yes I think it's Node.js' responsibility to fix this.

from graphile-engine.

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.