Skip to content

Conversation

kangsorang
Copy link

@kangsorang kangsorang commented Oct 9, 2025

Fix charset encoding mapping for UTF8MB4_0900_BIN

Problem

MySQL2 throws Encoding not recognized: 'undefined' error when connecting to MySQL 8.0+ servers using utf8mb4_0900_bin collation.

Root Cause

Mismatch between charsets.js and charset_encodings.js:

  • charsets.js defines UTF8MB4_0900_BIN = 309
  • charset_encodings.js array has length 309 (indices 0-308)
  • charset_encodings[309] returns undefined
  • Iconv.getDecoder(undefined) throws encoding error

Solution

Add missing encoding mapping for index 309 in charset_encodings.js.

Changes

  • File: lib/constants/charset_encodings.js
  • Change: Add 'utf8' entry at index 309 for UTF8MB4_0900_BIN

Impact

- Fix charset_encodings.js array missing index 309
- Resolves "Encoding not recognized: 'undefined'" error
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.76%. Comparing base (8143e42) to head (cb79669).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3855      +/-   ##
==========================================
- Coverage   89.78%   89.76%   -0.02%     
==========================================
  Files          86       86              
  Lines       13605    13606       +1     
  Branches     1606     1606              
==========================================
- Hits        12215    12214       -1     
- Misses       1390     1392       +2     
Flag Coverage Δ
compression-0 88.65% <100.00%> (-0.25%) ⬇️
compression-1 86.68% <100.00%> (-3.08%) ⬇️
static-parser-0 87.35% <100.00%> (+<0.01%) ⬆️
static-parser-1 86.93% <100.00%> (-1.19%) ⬇️
tls-0 89.11% <100.00%> (-0.09%) ⬇️
tls-1 88.65% <100.00%> (-0.91%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wellwelwel
Copy link
Collaborator

Thanks, @kangsorang

Do you think it's possible to have a test that covers this case (reproducing the failure if it doesn't have your modification)? Perhaps a temporary table with this encoding would solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encoding not recognized: 'undefined' error when connecting to MySQL 8.0+ servers that use utf8mb4_0900_bin collation.

2 participants