fix: remove prototype mutations that cause TypeError in sandboxed environments#404
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/hgourvest/node-firebird/sessions/be12fbd0-9a8a-4ca4-a9c1-57c2e303d40c Co-authored-by: mariuz <18359+mariuz@users.noreply.github.com>
…fix TypeError in sandboxed environments Agent-Logs-Url: https://github.com/hgourvest/node-firebird/sessions/be12fbd0-9a8a-4ca4-a9c1-57c2e303d40c Co-authored-by: mariuz <18359+mariuz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hgourvest/node-firebird/sessions/be12fbd0-9a8a-4ca4-a9c1-57c2e303d40c Co-authored-by: mariuz <18359+mariuz@users.noreply.github.com>
mariuz
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #403:
TypeError: Cannot assign to read only property 'toString' of object '#<Object>'In sandboxed environments that block prototype mutation (e.g. n8n 2.x Code nodes),
require('node-firebird')throws aTypeErrorbecause two pieces of code try to mutate prototypes during initialization.Root Causes
longnpm package — Thelongdependency mutatesLong.prototype.toString(and otherLong.prototypemethods) during module initialization. In sandboxed environments where prototype mutation is blocked, this fails withTypeError: Cannot assign to read only property 'toString' of object '#<Object>'.String.prototype.padLeftpolyfill inlib/index.js— Similarly mutatesString.prototype, which fails in the same sandboxed environments.Changes
lib/wire/serialize.jsrequire('long')addInt64: replacedLong.fromNumber(value)+writeInt32BEwithBuffer.writeBigInt64BE(BigInt(Math.trunc(value)))— consistent with the existingaddInt128approachreadInt64: replacednew Long(low, high).toNumber()withBuffer.readBigInt64BE()— consistent with the existingreadInt128approachNumber.MAX_SAFE_INTEGER(same behaviour as the previousLongimplementation)lib/index.jsString.prototype.padLeftpolyfill blocklib/utils.js.padLeft(n, c)calls with the native.padStart(n, c)(ES2017, already used elsewhere in the codebase)package.json/package-lock.jsonlongfromdependenciesTesting
All tests that passed before continue to pass. Test failures are unchanged (all pre-existing
Connect errorfailures due to no Firebird server in CI).