profile
viewpoint

mguida22/Connections 9

Add a new friend on all of your social media, with one scan of a QR code

mguida22/canada-eh 5

Make the internet a little more Canadian

mguida22/caravan 4

A multi-user gps/navigation app for iOS

biw/SocialCrypt 3

A Chrome extension that encrypts anything on the web

mguida22/alteryx-crypto 3

decryption tools

mguida22/buzzkill 3

:zap: Down with Buzzfeed

mguida22/degrees-to-directions 3

Convert degrees to directions

biw/readme-bot 2

[WIP] A github bot that automatically corrects readmes and makes a pull request with the changes

mguida22/elections 2

Real-time sentiment analysis of the 2016 Presidential Election

biw/typetac 1

[[wip]] - tachyons in typescript

startedpbeshai/use-query-params

started time in a day

startedwoltapp/blurhash

started time in 4 days

startedgoogle/eleventy-high-performance-blog

started time in 13 days

startedtmate-io/tmate

started time in 15 days

startedwinstonjs/logform

started time in 19 days

startedwinstonjs/winston

started time in 19 days

startedmourner/simplify-js

started time in a month

Pull request review commentsharedstreets/sharedstreets-js

add cleanup method to graph, use node v11, fix tests

 export class Graph {                     }                      previousNode = nodeId;-                }   -            +                }+                 var oneWay = obj.backReferenceId ? 'no' : 'yes';                 var roadClass = obj.roadClass.toLocaleLowerCase();                  if(roadClass == "other")-                    roadClass = "path"; // TODO add bike/ped modal restrictions to paths +                    roadClass = "path"; // TODO add bike/ped modal restrictions to paths                  osmRootElem.push({way:[{_attr:{id:nextEdgeId}},{tag:{_attr:{k:'highway', v:roadClass}}},{tag:{_attr:{k:'oneway', v:oneWay}}},...nodeIdElems]});                  nextEdgeId++;             }         }-          +         const writeFinished = new Promise((resolve, reject) => {-            xmlStreamWriter.on('finish', () => {  +            xmlStreamWriter.on('finish', () => {                 resolve(xmlPath);             });         });-        +          osmRootElem.close();         xmlStreamWriter.close();         //xmlStream.end();-      +         return writeFinished;     } +    /**+     * closes the LevelDB connection, which removes the lock so that others+     * can now connect to the same file.+     */+    async cleanup() {+        if (!this.db) return;++        return await this.db.close();+    }+

This is the main change to add a .cleanup method

mguida22

comment created time in a month

PullRequestReviewEvent

PR opened sharedstreets/sharedstreets-js

add cleanup method to graph, use node v11, fix tests

Hello!

We've been using sharedstreets-js at RideReport for a couple months now, and it's been a great help to build on the shared streets reference system! Thanks all of the work that has gone into this!

I've included a few changes here that we had to make to get sharedstreets-js working for our use cases. Feel free to use these changes, modify them, or ignore them.

  • add a note that sharedstreets-js requires node v11 due to it's dependency on OSRM
  • fix the ordering of expect statements within test_core
  • add a cleanup method to the graph

The only real functionality change is adding a cleanup method.

When a graph is built, it creates a LevelDB database to use. This node process puts a lock on the database, but doesn't release the lock until the node process ends (usually the node script finishes running, or if there's some error). This causes an issue when the same node process wants to get a new graph instance, built off of the same inputs. When a second graph is built with the same input parameters, it attempts to use the existing LevelDB, but sees the lock and throws an error.

/Users/mike/oss/sharedstreets-js/node_modules/levelup/lib/levelup.js:119
      return callback(new OpenError(err))
                      ^
OpenError: IO error: lock /Users/mike/.shst/cache/graphs/e8958d1c-1464-373e-b6b8-5a4959e309d2/db/LOCK: already held by process
    at /Users/mike/oss/sharedstreets-js/node_modules/levelup/lib/levelup.js:119:23
    at /Users/mike/oss/sharedstreets-js/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at /Users/mike/oss/sharedstreets-js/node_modules/deferred-leveldown/deferred-leveldown.js:31:21
    at /Users/mike/oss/sharedstreets-js/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
Emitted 'error' event at:
    at /Users/mike/oss/sharedstreets-js/node_modules/levelup/lib/levelup.js:60:19
    at /Users/mike/oss/sharedstreets-js/node_modules/levelup/lib/levelup.js:119:14
    at /Users/mike/oss/sharedstreets-js/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at /Users/mike/oss/sharedstreets-js/node_modules/deferred-leveldown/deferred-leveldown.js:31:21
    at /Users/mike/oss/sharedstreets-js/node_modules/abstract-leveldown/abstract-leveldown.js:38:14

This issue can be avoided by calling .close() on an open db connection when it's done being used.

These changes expose a .cleanup() method on the Graph, that closes the LevelDB connection. Once .cleanup() is called on an instance, a new instance can be created that accesses the same data. This allows for one continuous process to create and cleanup multiple sharedstreets Graphs.

+7823 -266

0 comment

6 changed files

pr created time in a month

create barnchmguida22/sharedstreets-js

branch : ride-report-updates

created branch time in a month

push eventmguida22/sharedstreets-js

push time in a month

startedniklasvh/html2canvas

started time in a month

startedSeb-C/kiss-orm

started time in 2 months

create barnchmguida22/sharedstreets-js

branch : fix-level-db-locking-issue

created branch time in 2 months

startedhtop-dev/htop

started time in 2 months

startedgoogle/leveldb

started time in 2 months

startednode-fetch/node-fetch

started time in 2 months

startedsharedstreets/mashnet

started time in 2 months

startedmikecao/umami

started time in 2 months

startedluin/readability

started time in 2 months

startedianstormtaylor/superstruct

started time in 2 months

startedstephenh/joist-ts

started time in 2 months

startedpypa/pipenv

started time in 2 months

startedlirantal/lockfile-lint

started time in 2 months

startedmapbox/tile-cover

started time in 3 months

startedsquaremo/amqp.node

started time in 3 months

startedHomebrew/brew

started time in 3 months

fork mguida22/mobility-metrics

Tools for collecting, processing, and interpreting mobility data using SharedStreets

fork in 3 months

startedsharedstreets/mobility-metrics

started time in 3 months

startedfredshone/citychef

started time in 3 months

startedvalhalla/valhalla

started time in 3 months

push eventmguida22/sharedstreets-js

Mike Guida

commit sha 5011cca3f9f65ccf790eb59b62fd9454f697a6b6

add more types for tile code

view details

Mike Guida

commit sha c3700e04d09ebd9ec7a041c6f31eebe51547fba1

formatting and types

view details

push time in 3 months

push eventmguida22/sharedstreets-js

Mike Guida

commit sha b49c0eec3b95c40b28b2a3eb42e68a63d435cf6a

make the tests pass

view details

push time in 3 months

push eventmguida22/sharedstreets-js

Mike Guida

commit sha 26aeaaebc2404a5ac81293abb1b74641f7cf08cf

cleanup all the things

view details

push time in 3 months

push eventmguida22/sharedstreets-js

Mike Guida

commit sha 142915b9f569875dca685f229921da7008ad3575

add note about using v8 for install

view details

Mike Guida

commit sha b5c57257f34b6abc52798953a7f3b40320c7f95e

fix type errors

view details

push time in 3 months

create barnchmguida22/sharedstreets-js

branch : fix-install

created branch time in 3 months

startedsharedstreets/sharedstreets-ref-system

started time in 3 months

startedProject-OSRM/osrm-backend

started time in 3 months

startedtimburgan/timburgan

started time in 3 months

issue openedtimburgan/timburgan

chess|move|c5b4|2411

Just push 'Submit new issue'. You don't need to do anything else.

created time in 3 months

startedsindresorhus/css-in-readme-like-wat

started time in 3 months

more