Next.js Discord

Discord Forum

Persistance of Instrumentation

Unanswered
shadow_aya posted this in #help-forum
Open in Discord
I'm unsure about the lifespan of global variables defined in [Instrumentation](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation)
The docs say:
For example, you might import a file that defines a set of global variables

but that would go against the serverless architecture. After defining for example a global class global.importer = Importer() which works with fs/path and imports in its constructor inside instrumentation, is the class rebuilt after it "expires", or does the app have persistent state for this?

note: I'm aware of the process.env.NEXT_RUNTIME === 'nodejs' check

0 Replies