Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0d959f7
feat: differentiate driver events from Firebird POST_EVENT API with f…
Copilot May 2, 2026
bcf8dd0
refactor: address code review - clarify transaction event param docs …
Copilot May 2, 2026
34a9317
fix: register attach listener synchronously inside callback to avoid …
Copilot May 2, 2026
848f949
fix: emit 'attach' event in attach() and fix createDatabase() to emit…
Copilot May 2, 2026
64d9b7a
fix: replace setImmediate with synchronous post-callback emit for 'at…
Copilot May 2, 2026
fc0021d
fix: pad SRP session key to full SHA-1 length (20 bytes) to prevent A…
Copilot May 2, 2026
1361bdf
fix: use sock.destroy() in endAndWaitForClose, add op_event guard in …
Copilot May 2, 2026
e0471bc
fix: improve op_event comment with Firebird protocol field names, doc…
Copilot May 2, 2026
6fa7856
fix: revert sock.destroy() to sock.end() - RST causes Firebird 3 to f…
Copilot May 2, 2026
56534b4
fix: skip registerEvent tests (op_que_events not implemented), fix ge…
Copilot May 2, 2026
b56b019
fix: clarify getState() test comment per code review
Copilot May 2, 2026
35750c8
fix: prevent _xdr buffer corruption on unknown opcodes + FIREBIRD_DEB…
Copilot May 2, 2026
76df708
fix: handle op_response_piggyback (72) in decodeResponse to prevent _…
Copilot May 2, 2026
2fe1983
fix: merge flaky double-attachEvent tests; add extensive protocol-lev…
Copilot May 2, 2026
44e7c4a
fix: increase SRP test timeout to 30s; add offline mock-server wire-p…
Copilot May 3, 2026
28ce64b
feat: add full SRP offline auth tests (FB3/4/5), BLR parser, timing l…
Copilot May 3, 2026
5700a7d
fix: code review - bounds checking in BLR parser, remove block scope,…
Copilot May 3, 2026
82f8e7a
docs: add SRP_PROTOCOL.md with comprehensive SRP auth documentation f…
Copilot May 3, 2026
d6ddf28
Changes before error encountered
Copilot May 3, 2026
c1c28d3
fix: increase SRP test timeout to 120s and add per-phase auth timing …
Copilot May 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node: [20, 22, 24]
firebird: [3, 4, 5]
Expand Down Expand Up @@ -72,6 +73,7 @@ jobs:
- name: Test (Linux)
run: |
export FIREBIRD_DATA=/firebird/data
export FIREBIRD_DEBUG=1
npm test

- name: Show Firebird log on failure
Expand Down
82 changes: 67 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,43 +377,95 @@ Firebird.attach(options, function (err, db) {
});
```

### Events
### Driver Events

Driver events are synchronous notifications emitted on the `Database` object for connection-level operations. Subscribe with `db.on(eventName, handler)`.

```js
Firebird.attach(options, function (err, db) {
if (err) throw err;

db.on('row', function (row, index, isObject) {
// index === Number
// isObject === is row object or array?
db.on('attach', function () {
// fired once the database is attached
});

db.on('detach', function (isPoolConnection) {
// isPoolConnection === Boolean
});

db.on('result', function (result) {
// result === Array
db.on('reconnect', function () {
// fired after the driver reconnects a dropped socket
});

db.on('attach', function () {});
db.on('error', function (err) {
// connection-level errors (socket errors, closed connection, etc.)
});

db.on('detach', function (isPoolConnection) {
// isPoolConnection == Boolean
db.on('transaction', function (options) {
// fired when a transaction is started (before server response)
// options === resolved transaction options object
});

db.on('reconnect', function () {});
db.on('commit', function () {
// fired when a transaction commit is sent
});

db.on('error', function (err) {});
db.on('rollback', function () {
// fired when a transaction rollback is sent
});

db.on('transaction', function (isolation) {
// isolation === Number
db.on('query', function (sql) {
// fired with the SQL string when a statement is prepared
});

db.on('commit', function () {});
db.on('row', function (row, index, isObject) {
// fired for each row decoded during a fetch
// index === Number, isObject === Boolean
});

db.on('rollback', function () {});
db.on('result', function (rows) {
// fired with the full rows array once all rows are fetched
// rows === Array
});

db.detach();
});
```

### Firebird Database Events (POST_EVENT)

Firebird database events are **asynchronous** notifications triggered by `POST_EVENT` inside PSQL triggers or stored procedures. They travel over a separate aux connection and are handled through `FbEventManager`.

> **Note:** Full POST_EVENT reception is not yet implemented. `attachEvent` and `registerEvent` are available, but actual event delivery requires completing the `op_que_events`/`op_event` wire-protocol implementation.

```js
Firebird.attach(options, function (err, db) {
if (err) throw err;

// 1. Open the aux event connection and get a FbEventManager
db.attachEvent(function (err, evtmgr) {
if (err) throw err;

// 2. Subscribe to one or more named events
evtmgr.registerEvent(['MY_EVENT'], function (err) {
if (err) throw err;

// 3. Listen for POST_EVENT notifications
evtmgr.on('post_event', function (name, count) {
// name === event name string (e.g. 'MY_EVENT')
// count === cumulative trigger count since last notification
});
});

// 4. Unsubscribe from events when no longer needed
// evtmgr.unregisterEvent(['MY_EVENT'], function (err) { ... });

// 5. Release the aux connection when done
// evtmgr.close(function (err) { ... });
});
});
```

### Escaping Query values

```js
Expand Down
Loading
Loading