[SERVER-60350] Can't use Buffer in mongodb 3.6 js script Created: 30/Sep/21  Updated: 18/Oct/21  Resolved: 18/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 3.6.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: norbert NNN Assignee: Edwin Zhou
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Hi,

I write a js script for mongodb 3.6.3 (Ubuntu 18.04) where I want to use js / nodejs "Buffer", but script execution says:

 

E QUERY [thread1] ReferenceError: Buffer is not defined 

The minimal script where I can reproduce the issue is:

 

let buff = new Buffer(10);
buff[1] = 1;

And the command line:

mongo localhost:27017/dev minimal.js

Can anybody help me, what did I wrong, or what am I miss?

Thank you



 Comments   
Comment by Edwin Zhou [ 18/Oct/21 ]

Hi moravas8051@gmail.com,

We appreciate the update and are happy to hear that mongosh was able to resolve your issue! I will now close this ticket.

Best,
Edwin

Comment by norbert NNN [ 18/Oct/21 ]

Hi Edwin Zhou,

 

thank you for the help, after migrating to mongodb 5.0 and execute the script via mongosh the problem gone away. This is a sufficient solution for me.

Note: executing the script via mongo command directly still fail on missing Buffer class.

Comment by Edwin Zhou [ 15/Oct/21 ]

Hi moravas8051@gmail.com,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please let us know if you've found success using the Buffer class in mongosh?

Best,
Edwin

Comment by Edwin Zhou [ 01/Oct/21 ]

Hi moravas8051@gmail.com,

Thanks for your report. MongoDB 3.6 reached end of life in April 2021 and is no longer supported, but I can provide limit guidance on this issue.

The new mongo Shell (mongosh) is a fully functional JavaScript and Node.js 14.x REPL environment for interacting with MongoDB deployments and the Buffer class is also functional when using mongosh. Please let us know if you're running into any issues using the new shell.

Best,
Edwin

Generated at Thu Feb 08 05:49:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.