Skip to content

Defer WRD YAML validation imports until they are used - #134

Closed
RichardHoekstra wants to merge 1 commit into
WebHare:mainfrom
RichardHoekstra:github/fix/wrd-defer-validation-import
Closed

RichardHoekstra wants to merge 1 commit into
WebHare:mainfrom
RichardHoekstra:github/fix/wrd-defer-validation-import

Conversation

@RichardHoekstra

Copy link
Copy Markdown
Contributor

Problem

Importing @webhare/wrd eagerly loads YAML validation and its generator dependency graph even when no YAML import is performed. Fresh native CallAsync runners also pay this startup cost.

Change

Load TrackedYAML inside the asynchronous importIntoWRDSchema helper through the existing CommonJS module-alias resolver. The public API stays unchanged.

Validation

  • wrd.nodejs.test_wrd_startup: fails before, passes after. Checks the import graph and valid/invalid YAML handling.
  • Existing WRD import/export tests, TypeScript compilation and unchanged ESLint checks pass.

Validated on the official 6.2 image for GitHub main a91a7a28, with the candidate sources installed. Full upstream CI has not been run.

@RichardHoekstra
RichardHoekstra requested a review from a team October 27, 2026 15:40
@unilynx

unilynx commented Oct 27, 2026

Copy link
Copy Markdown
Member

I'd rather not going down this route, before we know it hundreds of static imports have been rewritten to dynamic requires.

CallAsync is just very slow - I've measured nodejs process creation and basics imports itself already easily at 500ms, and even that 500ms is already unacceptable for a lot of situations. You're not going to get it to eg. 50ms where it's slowly getting reasonable to use in eg a dynamic page rendering. And even after startup things are slower than any other route, as you're not sharing any caches, whmanager or database connections which any other code.

I wouldn't use CallAsync/ImportJS anywhere a 500ms wait is not acceptable, so that basically leaves only background jobs and as a 'sidecar' to a Tollium application - where you just importjs once and reuse it running process for a long time. (and even there - switch to engine=wasm as soon as it's stable enough)

CallJS and backendServices have the advantage of using an already existing process. Don't use CallAsync where performance matters. Preferably don't use it anymore at all :-)

This branch was successfully deployed

1 active deployment
external-ci — afef9c70 Deployed Oct 27, 2026 by RichardHoekstra via setup #197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants