Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many fetch calls (20+) to "/api/settings/@jupyterlab/docmanager-extension" on the first load. #7874

Closed
ikiw opened this issue Feb 12, 2020 · 3 comments
Labels
status:resolved-locked
Milestone

Comments

@ikiw
Copy link
Member

@ikiw ikiw commented Feb 12, 2020

Description

Find too many fetch calls (20+) to /api/settings/@jupyterlab/docmanager-extension on the first load.
version - tried out in 1.2.6 & 1.2.3

Reproduce

  1. Open the Dev Tools
  2. Load JupyterLab
  3. Find the number of calls to docmanager-extension

Expected behavior

Avoid the redundant calls. Ideally should be only 1 fetch call.

Context

  • Operating System and version: Mac Cataline
  • Browser and version: Chrome V80
  • JupyterLab version: 1.2.6

Screenshot 2020-02-12 at 12 25 16 PM

Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Attached Screenshot
@jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Feb 12, 2020

This happens to me too on JLab 2.0rc0.

@jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Feb 12, 2020

I think it comes from these lines which reload the settings:

// If the document registry gains or loses a factory or file type,
// regenerate the settings description with the available options.
registry.changed.connect(() => settingRegistry.reload(pluginId));

@ikiw
Copy link
Member Author

@ikiw ikiw commented Feb 12, 2020

@jasongrout : Debugged it and found addWidgetFactory which emits this change event is invoked from a forEach loop.

https://github.com/jupyterlab/jupyterlab/blob/master/packages/application/src/mimerenderers.ts#L153

I was able to resolve it locally, by maintaining a check if there is already a promise yet to be resolved. Please let know if this approach is good. I can create a PR.


//callback to registry change that ensures not to invoke reload method when there is already a promise that is pending
    let reloadSettingsRegistry = () => {
      let promisePending = false;

      return async () => {
          if(!promisePending) {
            promisePending = true;
            await settingRegistry.reload(pluginId);
            promisePending = false;
          }
      };
    };

    // If the document registry gains or loses a factory or file type,
    // regenerate the settings description with the available options.
    registry.changed.connect(reloadSettingsRegistry());

ikiw pushed a commit to ikiw/jupyterlab that referenced this issue Feb 13, 2020
blink1073 pushed a commit that referenced this issue Feb 15, 2020
Resolve #7874 - stop too many fetch calls to docmanager-extension on …
@jasongrout jasongrout added this to the 2.0 milestone Feb 25, 2020
@lock lock bot added the status:resolved-locked label Mar 27, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:resolved-locked
Projects
None yet
Development

No branches or pull requests

2 participants