perf: improve performance when spec lint [INS-3724]
use web worker
@CurryYangxx very elegant approach. With node access in webworkers we have opened up some interesting performance options.
Should we spawn a new worker on every lint command or use a shared worker?
Now it will create just one worker when component first time render.And use a unique id to distinguish worker message.
Does this function handle race conditions?
Use the unique id for every message, only the result which id match the latested id will be updated.
Don't reload the spectral ruleset on every lint command
use a cache object in worker, only reload when ruleset path change
We still need to save spectralRun IPC because it is used in this action:https://github.com/Kong/insomnia/blob/cc421d1a3c041cebc059f5d421c4406c8fe75baf/packages/insomnia/src/ui/routes/actions.tsx#L736
Discussed offline and resolved several concerns, just added some minor comments. Overall it looks good to me but let's wait a bit as there might be some comments from other reviewers.
@ihexxa Good catch, update more logs and necessary termination