#Fresh and npm:mysql2 broken due to usage with Buffer

9 messages · Page 1 of 1 (latest)

lean spruce
#

Hi,

I am running Deno Fresh and npm:mysql2. I have a simple API route that inserts a row into the db. When I run the Fresh server in development mode, I get the following error:

00~error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'allocUnsafe')
    at Object.<anonymous> (file:///Users/pan/Library/Caches/deno/npm/registry.npmjs.org/mysql2/3.5.0/lib/commands/query.js:13:50)
    at Object.<anonymous> (file:///Users/pan/Library/Caches/deno/npm/registry.npmjs.org/mysql2/3.5.0/lib/commands/query.js:323:4)
    at Module._compile (node:module:718:36)
    at Object.Module._extensions..js (node:module:737:12)
    at Module.load (node:module:652:34)
    at Function.Module._load (node:module:534:16)
    at Module.require (node:module:671:23)
    at require (node:module:771:20)
    at Object.<anonymous> (file:///Users/pan/Library/Caches/deno/npm/registry.npmjs.org/mysql2/3.5.0/lib/commands/index.js:5:15)
    at Object.<anonymous> (file:///Users/pan/Library/Caches/deno/npm/registry.npmjs.org/mysql2/3.5.0/lib/commands/index.js:29:4)01~

However, when I simply start Fresh in produciton mode, everything works fine. I tried reproducing the issue and just copying the database related bits into separate files and running it. It worked fine, and the issue seems to happen when I run the Fresh server in development mode only.

Any thoughts? The error points to the Buffer global being used (Buffer.allocUnsafe). This is weird since this shouldn't happen in Deno

Thank you for your time.

#

Additionally, when setting strict rules, deno tries to access 'node_modules' all the way to the root directory:

00~┌ ⚠️  Deno requests read access to /Users/pan/Library/Caches/deno/npm/node_modules.
✅ Granted read access to /Users/pan/Library/Caches/deno/npm/node_modules.
┌ ⚠️  Deno requests read access to /Users/pan/Library/Caches/deno/node_modules.
✅ Granted read access to /Users/pan/Library/Caches/deno/node_modules.
┌ ⚠️  Deno requests read access to /Users/pan/Library/Caches/node_modules.
✅ Granted read access to /Users/pan/Library/Caches/node_modules.
┌ ⚠️  Deno requests read access to /Users/pan/Library/node_modules.
✅ Granted read access to /Users/pan/Library/node_modules.
┌ ⚠️  Deno requests read access to /Users/pan/node_modules.
✅ Granted read access to /Users/pan/node_modules.
┌ ⚠️  Deno requests read access to /Users/node_modules.
✅ Granted read access to /Users/node_modules.
┌ ⚠️  Deno requests read access to /node_modules.
✅ Granted read access to /node_modules.01~

Is there a best practice for read permissions for node_modules?

azure kindle
#

Is there a reason you're using an npm module over a deno module to do this?

lean spruce
#

No, I thought mysql2 is the best to use for mysql on deno. I might be wrong

azure kindle
lean spruce
#

How safe is it?

azure kindle
#

it's as safe as any other mysql library

#

don't use template strings with user information

lean spruce
#

Fair. Okay, thank you friend