-
Notifications
You must be signed in to change notification settings - Fork 40
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: dont spawn node for local ops #110
fix: dont spawn node for local ops #110
Conversation
@achingbrain @olizilla can you guys take a look at this one? My approach was to create a middleware that only runs in I wasn't sure about the Lines 6 to 12 in 78a563a
|
return next() | ||
} | ||
|
||
const ipfs = await startIpfs(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not return immediately so multiple parallel GET
requests to the server cause multiple IPFS nodes to be created. Better to have res.locals.ipfs
be a promise to resolve an IPFS node as multiple contexts can await on it and it'll only resolve once.
On that res.locals.ipfs
would be better as req.app.ipfs
so the single IPFS node is explicitly global to the app rather than storing it on res.locals
which imply per-request scoping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By which I mean, when I run this locally I see this sort of thing as requests from npm come in.
The rejected promises are caused by all the IPFS instances fighting over the locked ipfs-repo.
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
😈 Spawning an in-process IPFS node using repo at /Users/alex/.jsipfs
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5539) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
(node:5539) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
(node:5539) UnhandledPromiseRejectionWarning: Error: Lock file is already being held
at options.fs.stat (/Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/proper-lockfile/lib/lockfile.js:68:47)
at /Users/alex/Documents/Workspaces/ipfs-shipyard/npm-on-ipfs/node_modules/graceful-fs/polyfills.js:285:20
at FSReqWrap.oncomplete (fs.js:154:5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I fixed it in #111 but can't push to the incoming branch this PR is based on so have all the changes there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's weird, I don't think that happened to me 🤔
You're right, that is a better approach 👍
This reverts commit 36f4e8f.
Fixes #95.