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

File changes can trigger the same cell to be evaluated many times #158

Closed
mbostock opened this issue Nov 13, 2023 · 3 comments
Closed

File changes can trigger the same cell to be evaluated many times #158

mbostock opened this issue Nov 13, 2023 · 3 comments
Labels
bug Something isn’t working question Further information is requested

Comments

@mbostock
Copy link
Member

Because a file can be referenced, either directly or indirectly, by multiple cells, we may end up seeing multiple watch events occur roughly concurrently that cause a single cell to be refreshed many times. We should debounce file watching, related #157, so that these refreshes are coalesced.

@mbostock mbostock added the bug Something isn’t working label Nov 13, 2023
@mbostock mbostock added this to the Early access milestone Nov 13, 2023
@Fil
Copy link
Contributor

Fil commented Feb 12, 2024

I have not been able to reproduce this issue.

Here's my best shot:

```js
const a = [];
```

```js
display(b);
```

```js
const file1 = FileAttachment("double-trouble.txt").text();
```

```js
const file2 = FileAttachment("double-trouble.txt").text();
```

```js
const l1 = display(file1.length);
```

```js
file1;
file2;
l1;
if (a.length > 5) a.splice(0, a.length - 5);
a.push(+new Date() % 100000);
const b = a;
```

I tried with double-trouble.txt as a file or as a data loader, but modifying it never resulted in adding more than 1 timestamp to the b array.

example data "loader":

await new Promise(ok => setTimeout(ok, 1000));
console.log(+Date.now());

@Fil Fil self-assigned this Feb 12, 2024
@Fil Fil added the question Further information is requested label Feb 12, 2024
@mbostock
Copy link
Member Author

It’s not visible to the client because the runtime coalesces redefinitions within an animation frame. But if you watch the socket events you should see that too many messages are sent when the file changes.

@mbostock mbostock modified the milestones: General availability, Future Feb 13, 2024
@Fil Fil removed their assignment Feb 13, 2024
@mbostock
Copy link
Member Author

mbostock commented Mar 4, 2024

Fixed in #843.

@mbostock mbostock closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants