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: handle empty data in column cells gracefully to avoid viz-switching runtime errors #71

Merged
merged 1 commit into from
Jul 14, 2021

Conversation

hydrosquall
Copy link
Member

@hydrosquall hydrosquall commented Jul 4, 2021

Motivation

Changes

  • Use JSON.stringify instead of .toString(), this handles null and undefined gracefully (the previous error happens because those empty values don't have a toString() attached. We technically have the option of ignoring those values entirely, but it might be unexpected behavior depending on the user.
  • Use a Set to find unique values in each column rather than looping through the entire array twice as the previous find / reduce mechanism was doing.

Testing

(GIF: https://a.cl.ly/qGu5nReq )
Screen Recording 2021-07-10 at 09 27 11 PM

📦 Published PR as canary version: 8.2.12--canary.71.a7f202e.0

✨ Test out this PR locally via:

npm install @nteract/[email protected]
# or 
yarn add @nteract/[email protected]

@hydrosquall hydrosquall added the release Create a release when this pr is merged label Jul 4, 2021
@hydrosquall hydrosquall changed the title fix: handle missing data in column cells more gracefully fix: handle empty data in column cells gracefully to avoid viz-switching runtime errors Jul 4, 2021
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-viz-switching-bug branch 2 times, most recently from 261e24a to 1b84808 Compare July 11, 2021 01:15
…en finding unique values

Previously, there would be runtime errors if users switched to columns with cell values that lacked
a toString() method

Now, the app does not crash when columns contain cell values that do not have toString()
inside, such as "undefined" or "null"
@hydrosquall hydrosquall force-pushed the cameron.yick/fix-viz-switching-bug branch from 1b84808 to a7f202e Compare July 11, 2021 01:23
@hydrosquall hydrosquall self-assigned this Jul 11, 2021
@hydrosquall hydrosquall added the bug Something isn't working label Jul 11, 2021
@hydrosquall hydrosquall marked this pull request as ready for review July 11, 2021 01:31
: uniques,
[],
);
const uniqueValues = dim1 === "none" ? [] : getUniqueValues(sortedData, dim1);
Copy link
Member Author

Choose a reason for hiding this comment

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

If a user provides a dataset with a column called none, it's going to break other things in the data-explorer because none is already heavily used internally. If we rewrite this in the future, we may want to use a namespaced constant like $$_DX_NONE_$$ for our none column name to reduce the risk of collision with a user's dataframe. For now, I think it's out of scope to change that at the same time.

@@ -20,7 +20,7 @@ export const sortByOrdinalRange = (
rAccessor: string | (() => void),
secondarySort: string,
data: Dx.DataProps["data"],
): any[] => {
): Dx.DataProps["data"] => {
Copy link
Member Author

Choose a reason for hiding this comment

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

What goes in, comes out again

@willingc
Copy link
Member

Thanks @hydrosquall. Tagging @emeeks @rgbkrk @MSeal since Cameron's use of replay is interesting.

Cameron, how are you liking replay?

@jasonLaster
Copy link

Hey!

Jason from the replay.io team. Happy to answer any questions as well :)

@hydrosquall
Copy link
Member Author

hydrosquall commented Jul 12, 2021

Cameron, how are you liking replay?

@willingc I like using it! I'm trying to use it as much as I can when doing open source JS work that doesn't involve a WebGL component, as that isn't supported yet.

The biggest advantage vs just capturing a GIF or video is that other reviewers can explore a captured sequence application state without needing to spin up the app themselves, and add logging statements to surrounding files as necessary.

This particular bug was a bit of a simplistic example since triggering the bug only required 1 click to trigger, but I can see this being even more valuable to demonstrate bugs with trickier reproduction paths.

I think the "commenting" feature to collaboratively discuss bugs synced with particular moments in time has potential, but I haven't used this feature extensively.

@willingc
Copy link
Member

@jasonLaster Thanks for offering to answer questions. If a team is already using Cypress, what are the best practices to add replay.io?

@hydrosquall
Copy link
Member Author

I'm going to merge this PR for the purpose of removing the original runtime bug, but feel free to continue discussing replay.io on this thread. I'll chime in here based on my understanding so far.

From what I gather using Replay.io wouldn't directly affect a team's usage of Cypress, since Cypress would be for running programmatic tests as part of CI, whereas Replay.io is for documenting / human-generated behaviors inside of bug reports. Someone might choose to write a new Cypress test when they fix a bug that was described in a Replay.io recording, but I don't think there's currently a workflow for capturing user actions and generating a test automation script with Replay directly.

@hydrosquall hydrosquall merged commit 1325456 into main Jul 14, 2021
@github-actions
Copy link

🚀 PR was released in v8.2.12 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Jul 14, 2021
@hydrosquall hydrosquall deleted the cameron.yick/fix-viz-switching-bug branch July 14, 2021 01:13
@jasonLaster
Copy link

@willingc yep - seconding what @hydrosquall said. Replay.io is great when folks want to record a bug and share it with others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants