OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
131 stars 36 forks source link

Editor loading very slowly #2617

Open christad92 opened 2 weeks ago

christad92 commented 2 weeks ago

Today during a demo I noticed that the editor was very slow when loading and had to wait for about one minute for it to load. The input and output panels were loaded but the editor panel was blank.

Workflow: https://app.openfn.org/projects/fdfdf286-aa8e-4c9e-a1d2-89c1e6928a2a/w/b0849f2a-ac91-4689-b813-ff80c077a2cc?v=87&a=1a12c9c8-6675-49a1-a00f-cbe98357cd90&m=expand&s=d3ef54de-4b6c-4655-a8aa-21d504f1dc27#log

stuartc commented 2 weeks ago

I can't reproduce this, has it happened subsequently? With my cache disabled I timed this as fully usable in 5 seconds.

josephjclark commented 1 week ago

I suspect this is related to cache and slow internet. There's like 6mb of editor stuff that needs downloading and if its not cached then it will take some time.

josephjclark commented 23 hours ago

Huh - I just saw this!

I loaded this workflow on app.openfn.org, using a good fast stable connection and surely with the actual editor source cached.

It took like 30 seconds for the job code to load.

My dev console shows this:

Job not found 6637fdf1-62f4-446d-8f59-98b7b37dc3e3

Image

That is the job I'm looking at, which did subsequently load.

I think this issue might actually: sometimes there's an error loading job expressions into the inspector and that stops the editor loading

josephjclark commented 23 hours ago

Yes, the editor component will not mount until the workflow has been loaded into the zustand store.

The error in my console was thrown in the editor's mount code:

  render() {
    const { adaptor, disabled, disabledMessage, jobId } = this.el.dataset;

    checkAdaptorVersion(adaptor);

    this.findWorkflowEditorStore().then(workflowStore => {
      const job = workflowStore.getState().getById<Lightning.Job>(jobId);

      if (!job) {
        console.error('Job not found', jobId);
        return;
      }

      if (JobEditorComponent) {
        this.componentRoot?.render(
          <JobEditorComponent
            adaptor={adaptor}
            source={job.body}
            metadata={this.metadata}
            disabled={disabled === 'true'}
            disabledMessage={disabledMessage}
            onSourceChanged={src => this.handleContentChange(src)}
          />
        );
      }
    });
  },
josephjclark commented 23 hours ago

Refreshing that some page sometimes loads instantly, sometimes takes a while. I'm watching a loading spinner as I type this comment.