near / react-on-chain

Improved execution layer for NEAR decentralized frontend components
https://roc-docs.near.dev/
23 stars 5 forks source link

Compiler worker processes requests before initialization is finished #386

Open andy-haynes opened 1 month ago

andy-haynes commented 1 month ago

The compiler worker should be waiting for initialization to finish before processing new requests, see: #382. This mainly impacts local environments - the only production issue is a failed lookup for new web IDE Components, though it has no impact on the user.

Rather than having consumers of useCompiler responsible for waiting on initialization, I'm leaning towards having compileComponent wait on pending initialization like it does currently with LightningCSS. E.g. something like

init(...) {
  let initResolver;
  this.initialization = new Promise((res) => { initResolver = res; });
  ...
  initResolver();
}
...
compileComponent(...) {
  await this.cssParser.init();
  await this.initializer;
}