Coder Social home page Coder Social logo

Comments (3)

mbostock avatar mbostock commented on July 17, 2024

This is a known limitation of the preview server. As @Fil mentioned in #1051:

In preview, by contrast, [computing the modification time] happens before the data loader has had a chance to run. So, when the cache is stale, you get stale information — but the situation solves itself on the next page load. (It is not possible to solve this in any other way as we can’t predict the future, and don’t want to wait for the loader to have finished running before we send the page to the browser.)

In other words, when you edit a referenced file, the preview server immediately detects the change and notifies the client over the websocket so that the client can download the latest version of the file. However, when this referenced file is generated by a data loader, we know that the data loader has been changed, but we don’t know yet what the contents of the file are because the data loader is still running.

Perhaps there are two ways we could fix this:

  1. We could wait until the data loader finishes running before reporting it to the client. This would be quite a disruptive change to implement because currently data loaders are triggered lazily by the client requesting a file. It would also mean that page rendering would have to stall until all referenced data loaders have finished, which I expect is a much worse developer experience. (You’d never see any loading indicators and instead you’d see the browser waiting for the page to load with nothing visible.)
  2. During preview, or perhaps just when the data loader has been invalidated and is newer than its previous output, we could report the modification time as the modification time of the data loader source rather than the cached output. This is a “lie” in a sense, but it’s probably a convenient lie from the perspective of the client, since the client now wouldn’t have to handle the case where the lastModified property is undefined.

I think we can do the latter pretty easily. I’ll try that.

from framework.

mbostock avatar mbostock commented on July 17, 2024

Edit: this applies to all file updates, not just data loaders! We were forgetting to populate lastModified on the diff. Will fix.

from framework.

timmolendijk avatar timmolendijk commented on July 17, 2024

Edit: this applies to all file updates, not just data loaders! We were forgetting to populate lastModified on the diff. Will fix.

Exactly :)

Wonderful, thanks for the fix.

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.