#Best way to debug an error in a dep of a dep in a Bun monorepo?

1 messages · Page 1 of 1 (latest)

daring ridge
#

Does anyone have any suggestions for when something in a monorepo fails on bun but works on node, more specifically when an error happen in an dependency of a dependency?

┌ api#dev > cache miss, executing 229e22d89c2de972 
│ $ bun --watch run .
│ 1 | 'use strict'2 | 
│ 3 | const { LRUCache } = require('lru-cache')
│ 4 | 
│ 5 | const MEMOIZED = new LRUCache({
│                      ^
│ TypeError: undefined is not a constructor (evaluating 'new LRUCache({
│     max: 500,
│     maxSize: 52428800,
│     ttl: 180000,
│     sizeCalculation: (entry, key) => key.startsWith("key:") ? entry.data.length : entry.length
│   })')
│       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/memoization.js:5:18
│       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/get.js:8:7
│       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/index.js:3:7
│       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/make-fetch-happen/lib/cache/entry.js
│ :4:7
│       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/make-fetch-happen/lib/cache/index.js
│ :2:7
daring ridge
daring ridge
#

@jaunty sable ^

daring ridge
#

Bumping this

daring ridge
#

bumping this again

silk pecan
#

@daring ridge are you still seeing this on Bun v1.1.24?

#

this particular error I believe was fixed in around 1.1.20

daring ridge
# silk pecan <@461862173044375572> are you still seeing this on Bun v1.1.24?

Yes:

bot:dev: 1 | 'use strict'
bot:dev: 2 |
bot:dev: 3 | const { LRUCache } = require('lru-cache')
bot:dev: 4 |
bot:dev: 5 | const MEMOIZED = new LRUCache({
bot:dev:                      ^
bot:dev: TypeError: undefined is not a constructor (evaluating 'new LRUCache({
bot:dev:     max: 500,
bot:dev:     maxSize: 52428800,
bot:dev:     ttl: 180000,
bot:dev:     sizeCalculation: (entry, key) => key.startsWith("key:") ? entry.data.length : entry.length
bot:dev:   })')
bot:dev:       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/memoization.js:5:18
bot:dev:       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/get.js:8:7
bot:dev:       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/cacache/lib/index.js:3:7
bot:dev:       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/make-fetch-happen/lib/cache/entry.js:4:7
bot:dev:       at /Users/net-tech-/Developer/kiai/packages/database/node_modules/make-fetch-happen/lib/cache/index.js:2:7

03:05:12 ❯ bun --version
1.1.24
#

It's a monorepo with turborepo but it shouldn't make a difference

#

i've spent the last hour digging through dependency trees looking for old versions of lru-cache in case that is the issue

silk pecan
#

hmm

#

yeah looks like in older versions it would be const LRUCache = require("lru-cache")

daring ridge
#

yep

silk pecan
#

so does this mean bun is installing the wrong version of lru-cache in the monorepo?

daring ridge
#

no i think the issue is more on the people who make the dependency of a dependency of a dependency using very old versions, no?

#

if i were to force everything to use the newest version of lru-cache i dont know if it would fix it

silk pecan
#

in that case, you can use "resolutions": { "lru-cache": "11" }

daring ridge
#

some dependencies are using very old versions (i.e., v5)

silk pecan
#

in package.json

daring ridge
#

let me try it out

daring ridge
silk pecan
#

yeah