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

Fix undefined error when checkpoints is empty #7567

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

jdavid
Copy link
Contributor

@jdavid jdavid commented Jan 23, 2025

      const checkpoints = await context?.listCheckpoints();       <== if checkpoints is an empty array
      if (!checkpoints) {                                         <== this will be false
        return;
      }
      const checkpoint = checkpoints[checkpoints.length - 1];     <== then checkpoint will be undefined
      node.textContent = trans.__(
        'Last Checkpoint: %1',
        Time.formatHuman(new Date(checkpoint.last_modified))      <== here will trigger an undefined error
      );

We found the problem while integrating jupyterlite with a FastAPI project.

Copy link
Contributor

Binder 👈 Launch a Binder on branch jdavid/notebook/fix-js-undefined-error

jdavid added a commit to ironArray/Caterva2 that referenced this pull request Jan 23, 2025
jdavid added a commit to ironArray/Caterva2 that referenced this pull request Jan 23, 2025
@jtpio jtpio added the bug label Jan 23, 2025
@jtpio jtpio added this to the 7.3.x milestone Jan 23, 2025
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 8b3b5b3 into jupyter:main Jan 24, 2025
33 of 34 checks passed
@jtpio
Copy link
Member

jtpio commented Jan 24, 2025

@meeseeksdev please backport to 4.3.x

Copy link

lumberbot-app bot commented Jan 24, 2025

Something went wrong ... Please have a look at my logs.

It seems that the branch you are trying to backport to does not exist.

@jtpio
Copy link
Member

jtpio commented Jan 24, 2025

@meeseeksdev please backport to 7.3.x

@jtpio
Copy link
Member

jtpio commented Jan 24, 2025

We found the problem while integrating jupyterlite with a FastAPI project.

Do you need this change in JupyterLite soon? It may take a little while to propagate there as this would first need to be available in a Notebook release.

Normally this issue should not have too much of an impact, except for some errors in the dev tools console?

@jdavid
Copy link
Contributor Author

jdavid commented Jan 24, 2025

In our case the error breaks the notebook, but I don't need the fix quickly, we already patch the file.
Thanks for merging!

jtpio pushed a commit that referenced this pull request Jan 24, 2025
jdavid added a commit to ironArray/Caterva2 that referenced this pull request Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants