Skip to content

buffer empty: handled error when value is null - #8661

Closed
miteshsondhi wants to merge 1 commit into
sequelize:masterfrom
miteshsondhi:master
Closed

miteshsondhi wants to merge 1 commit into
sequelize:masterfrom
miteshsondhi:master

Conversation

@miteshsondhi

@miteshsondhi miteshsondhi commented Nov 20, 2017 •

Copy link
Copy Markdown

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

value.length is throw an exception when value=null I have fixed that please check

@codecov

codecov Bot commented Nov 20, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #8661 into master will increase coverage by 5.03%.
The diff coverage is 100%.

@sushantdhiman

Copy link
Copy Markdown
Contributor

Can you add a test to prevent regression? When did you encounter this issue?

@miteshsondhi

Copy link
Copy Markdown
Author

@sushantdhiman thanks for reviewing I don't know how to setup test env locally. But I can provide an example which will produce this issue.

https://github.com/miteshsondhi/sample-geopoint.git

above is the github link please run it

npm install
node index.js

My pr will fix the issue thanks

@doublesharp

Copy link
Copy Markdown

I'm having this issue as well but only using sequelize with [email protected], I don't have the problem with [email protected].

Stacktrace

error: uncaughtException: Cannot read property 'length' of null 
date=Tue Nov 21 2017 12:26:15 GMT-0800 (PST), 
pid=37117, 
uid=501, 
gid=20, 
cwd=/workspace, 
execPath=/home/.nvm/versions/node/v9.0.0/bin/node, 
version=v9.0.0, 
argv=[/home/.nvm/versions/node/v9.0.0/bin/node, /workspace/bin/server], 
rss=105488384, 
heapTotal=59039744, 
heapUsed=51240944, 
external=3997834, 
loadavg=[2.6982421875, 2.3056640625, 2.28271484375], 
uptime=81492, 
trace=[
  column=15, file=/workspace/node_modules/sequelize/lib/dialects/mysql/data-types.js, function=parse, line=153, method=null, native=false, 
  column=39, file=/workspace/node_modules/sequelize/lib/dialects/mysql/connection-manager.js, function=ConnectionManager._typecast, line=59, method=_typecast, native=false, 
  column=21, file=/workspace/node_modules/generate-function/index.js, function=new TextRow (eval at line.toFunction, line=55, method=toFunction, native=false, 
  column=13, file=/workspace/node_modules/mysql2/lib/commands/query.js, function=Query.row, line=231, method=row, native=false, 
  column=20, file=/workspace/node_modules/mysql2/lib/commands/command.js, function=Query.Command.execute, line=40, method=execute, native=false, 
  column=28, file=/workspace/node_modules/mysql2/lib/connection.js, function=Connection.handlePacket, line=515, method=handlePacket, native=false, 
  column=16, file=/workspace/node_modules/mysql2/lib/connection.js, function=PacketParser.onPacket, line=94, method=onPacket, native=false, 
  column=14, file=/workspace/node_modules/mysql2/lib/packet_parser.js, function=PacketParser.executeStart, line=77, method=executeStart, native=false, column=29, file=/workspace/node_modules/mysql2/lib/connection.js, function=null, line=102, method=null, native=false, 
  column=13, file=events.js, function=emitOne, line=125, method=null, native=false, 
  column=7, file=events.js, function=Socket.emit, line=221, method=emit, native=false, 
  column=12, file=_stream_readable.js, function=addChunk, line=265, method=null, native=false, 
  column=11, file=_stream_readable.js, function=readableAddChunk, line=252, method=null, native=false, 
  column=10, file=_stream_readable.js, function=Socket.Readable.push, line=209, method=push, native=false, 
  column=20, file=net.js, function=TCP.onread, line=598, method=onread, native=false
], 
stack=[
  TypeError: Cannot read property 'length' of null,
     at parse (/workspace/node_modules/sequelize/lib/dialects/mysql/data-types.js:153:15),     
     at ConnectionManager._typecast (/workspace/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:59:39),     
     at new TextRow (eval  at line.toFunction (/workspace/node_modules/generate-function/index.js:55:21), <anonymous>:41:32),     
     at Query.row (/workspace/node_modules/mysql2/lib/commands/query.js:231:13),     
     at Query.Command.execute (/workspace/node_modules/mysql2/lib/commands/command.js:40:20),     
     at Connection.handlePacket (/workspace/node_modules/mysql2/lib/connection.js:515:28),     
     at PacketParser.onPacket (/workspace/node_modules/mysql2/lib/connection.js:94:16),     
     at PacketParser.executeStart (/workspace/node_modules/mysql2/lib/packet_parser.js:77:14),     
     at Socket.<anonymous> (/workspace/node_modules/mysql2/lib/connection.js:102:29),     
     at emitOne (events.js:125:13),     
     at Socket.emit (events.js:221:7),     
     at addChunk (_stream_readable.js:265:12),     
     at readableAddChunk (_stream_readable.js:252:11),     
     at Socket.Readable.push (_stream_readable.js:209:10),     
     at TCP.onread (net.js:598:20)
]

@doublesharp

Copy link
Copy Markdown

@sushantdhiman I am only able to reproduce this going against an actual MySQL/MariaDB instance so I am not sure how to add a regression test. Can you provide assistance in adding coverage if it is needed - the change is pretty small and does prevent the error shown my stacktrace

This is preventing me from being able to upgrade to the latest Mysql2 module.

Thanks!

@doublesharp

Copy link
Copy Markdown

This is the change that explicitly says that it is now returning NULL instead of an empty Buffer, which the Sequelize code is not accounting for.

sidorares/node-mysql2@21dfe3d
sidorares/node-mysql2@a43e8da

The comment in the Sequelize code (https://dev.mysql.com/worklog/task/?id=2381) notes that the EMPTY POINT response is not yet implemented in MySQL Server as is planned for 7.0 - the current release is 5.7. As such it is returning a NULL which mysql2 is now passing along and causing Sequelize to throw an error when checkingvalue.length. The comment just above it says // Empty buffer, MySQL doesn't support POINT EMPTY, but it is actually a NULL.

@sushantdhiman

Copy link
Copy Markdown
Contributor

6931c79

@sushantdhiman sushantdhiman mentioned this pull request May 19, 2018
1 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants