Coder Social home page Coder Social logo

Comments (5)

yhahn avatar yhahn commented on June 13, 2024

Ugh, we should keep the locking IO but fix this. Want to add an additional test that has a failed load and demonstrates the problem?

https://github.com/mapbox/node-tilejson/blob/master/test/tilejson.test.js#L118

Then let's look into what's going on and fix.

from node-tilejson.

mikemorris avatar mikemorris commented on June 13, 2024

@yhahn Interestingly, the locking IO seems to work just fine in a for loop, performing the file IO only once, but calling many callbacks. I was able to reproduce the issue using Step though https://github.com/mapbox/node-tilejson/blob/broken-locking/test/tilejson.test.js#L188-222

from node-tilejson.

mikemorris avatar mikemorris commented on June 13, 2024

@yhahn "Fixed" in 4978876 by switching from EventEmitter to a simple array of callbacks and a while loop. I'm uncertain if this actually addresses the underlying problem, but all tests are passing now. My theory is that this problem was caused by relying on the many callback to move to the next step before deleting the lock, in which case a new many callback was added to the (still existing and locked) EventEmitter from the next step, and never executed because the EventEmitter then gets deleted afterwards. A race condition may still exist here (will the next callback always be added before the while loop exits?), would like to discuss how this should be handled correctly.

from node-tilejson.

yhahn avatar yhahn commented on June 13, 2024

O_o

Only small thing I would vet here is whether the callbacks should be called using pop() or shift(). I'm assuming the caller will expect the first callbacks added to be called first once the lock is release.

from node-tilejson.

mikemorris avatar mikemorris commented on June 13, 2024

@yhahn Ack, yea good catch, shift() would probably make more sense here, done in 81de5f4

from node-tilejson.

Related Issues (13)

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.