hdresearch / nolita

Work with web-enabled agents quickly — whether running a quick task or bootstrapping a full-stack product.
https://nolita.ai
MIT License
86 stars 5 forks source link

various: update zod/openapi, consolidate zod location #117

Closed matildepark closed 1 month ago

matildepark commented 1 month ago

Tested by pushing nolita@experimental tag and running in a Docker container running node 20 and no other dependencies. I think this is safe to hit dev for further testing of functionality.

matildepark commented 1 month ago

Poking around and now it seemingly doesn't get anything coming in from requests, but again ... only in prod (running npx nolita@experimental serve; pnpm run build will produce a normal working build):

TypeError: Cannot destructure property 'agent' of 'c.req.valid(...)' as it is undefined.
    at Array.<anonymous> (/usr/src/app/nolita/node_modules/nolita/dist/server/browser/launch.js:68:20)
    at _OpenAPIHono.dispatch (/usr/src/app/nolita/node_modules/hono/dist/cjs/hono-base.js:210:38)
    at fetch (/usr/src/app/nolita/node_modules/hono/dist/cjs/hono-base.js:236:17)
    at Server.<anonymous> (/usr/src/app/nolita/node_modules/@hono/node-server/dist/index.js:440:13)
    at Server.emit (node:events:519:28)
    at parserOnIncoming (node:_http_server:1140:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)

My only guess is a stray npm warn ERESOLVE overriding peer dependency preventing conversion of JSON to whatever Hono seems to want, but npm doesn't really tell you what it can't resolve. Assessing the dependency graph again...

matildepark commented 1 month ago

The peer dependency thing seems rather moot so no wonder it doesn't report anything.

npm verbose attempt to log crashed ERESOLVE overriding peer dependency {
npm verbose   code: 'ERESOLVE',
npm verbose   edge: {
npm verbose     type: 'peer',
npm verbose     name: 'zod',
npm verbose     spec: '^3.23.3',
npm verbose     error: 'INVALID',
npm verbose     from: {
npm verbose       name: 'zod-to-json-schema',
npm verbose       version: '3.23.1',
npm verbose       location: 'node_modules/zod-stream/node_modules/zod-to-json-schema',
npm verbose       isWorkspace: false,
npm verbose       dependents: [Array]
npm verbose     }
npm verbose   },
npm verbose   dep: {
npm verbose     name: 'zod',
npm verbose     version: '3.23.8',
npm verbose     whileInstalling: {
npm verbose       name: 'zod-stream',
npm verbose       version: '1.0.3',
npm verbose       path: '/usr/src/app/nolita/node_modules/zod-stream'
npm verbose     },
npm verbose     location: 'node_modules/zod',
npm verbose     isWorkspace: false,
npm verbose     dependents: [ [Object] ]
npm verbose   },
npm verbose   force: false,
npm verbose   isMine: false,
npm verbose   strictPeerDeps: false,
npm verbose   current: {
npm verbose     name: 'zod',
npm verbose     version: '3.22.4',
npm verbose     location: 'node_modules/zod',
npm verbose     isWorkspace: false,
npm verbose     dependents: [ [Object] ]
npm verbose   },
npm verbose   peerConflict: {
npm verbose     name: 'zod',
npm verbose     version: '3.22.4',
npm verbose     location: 'node_modules/zod',
npm verbose     isWorkspace: false,
npm verbose     dependents: [ [Object] ]
npm verbose   }
npm verbose } TypeError: Cannot read properties of undefined (reading 'extraneous')
npm verbose     at printNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:24:13)
npm verbose     at explainNode (/usr/local/lib/node_modules/npm/lib/utils/explain-dep.js:4:3)
npm verbose     at explain (/usr/local/lib/node_modules/npm/lib/utils/explain-eresolve.js:39:16)
npm verbose     at #tryWriteLog (/usr/local/lib/node_modules/npm/lib/utils/display.js:345:41)
npm verbose     at /usr/local/lib/node_modules/npm/lib/utils/display.js:233:28
npm verbose     at process.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/display.js:95:10)
npm verbose     at process.emit (node:events:531:35)
npm verbose     at Object.warn (/usr/local/lib/node_modules/npm/node_modules/proc-log/lib/index.js:62:22)
npm verbose     at PlaceDep.warnPeerConflict (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:496:9)
npm verbose     at new PlaceDep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:165:14)

All this is complaining about schema-stream, our lone dependency pinned to 3.22.4 zod, for some reason, even though it isn't, on the same version, on GitHub meaning their npm code and their GitHub code differ. Everything else will take ^3.22 and up. This shouldn't affect Hono not receiving incoming JSON, though why only built via this CI and deployed to npm? Let me try building one and pushing to experimental.

edit: Building locally and pushing to experimental produces the same result. If you npm i nolita@experimental and then run node ./node_modules/nolita/dist/bin/index.js serve, it will produce the same result. This seems like a dependency tree thing still.

matildepark commented 1 month ago

Anyway, filed that, but I genuinely have no idea what's going on here anymore. Are you able to debug incoming JSON blobs ... only in prod???

edit: I mean, given it only happens when installing straight from npm, that it's a dependency thing, I can't understand why npm i && npm run build produces a working build. That would make me think there's a dev dependency problem. We did have json-to-zod-schema in devDependencies when it shouldn't have been there. But other packages import it, so it still appears in prod.

matildepark commented 1 month ago

If we use @hono/zod-openapi's z, everything seems hunky dory. The difference between this PR and #115 is that this PR uses the latest versions of everything, so ... maybe this is the one you really want.