Skip to content

Hooks: proper nesting with savepoints, customisation, fix tests - #206

Merged
daffl merged 1 commit into
feathersjs:masterfrom
vonagam:refactor-hooks
Jun 10, 2019
Merged

daffl merged 1 commit into
feathersjs:masterfrom
vonagam:refactor-hooks

Conversation

@vonagam

@vonagam vonagam commented Jun 10, 2019

Copy link
Copy Markdown
Member

Instead of simply incrementing a counter start hook creates a nested transaction with a savepoint. Counter way fails with complex scenarios like new third test for hooks.

Added getKnex option for start hook. Allows to specify where to get knex from, so the hook can be used not only with feathers-knex service. Useful for feathers-objection and tests.

Fixed previous test and added two additional. Previous test was actually not working, it was passing simply because "people2" table was not existent. And initial design of replacing "COMMIT;" with "COMMITA;" was a mistake because a connection was not released afterwards (it was working initially because it was the last test, but stopped to be in #181).

Remark on history: as i understand in an attempt to fix the problem caused by the broken test #181 included a removal of some lines in hooks.js (a, b, c, d), that caused regression in unhandled rejections, so #196 was needed. It had advantage over initial solution in handling rejections from an establishing phase, but ate rejections from an execution phase (this should have been visible if the broken test was working and not turned off in #181). Now both establishing and execution phases should be handled right.

@daffl
daffl merged commit 3ff7e04 into feathersjs:master Jun 10, 2019
@daffl

daffl commented Jun 10, 2019 •

Copy link
Copy Markdown
Member

Awesome, thank you for getting this fixed! Released as v5.1.0

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.

2 participants