senecajs / seneca-transport

Seneca micro-services message transport over TCP and HTTP.
MIT License
63 stars 45 forks source link

handle_entity loses tx$ #52

Closed gkubisa closed 8 years ago

gkubisa commented 8 years ago

handle_entity currently creates the entities using this._context.seneca, which does not have the correct tx$ value set. Consequently, any operations on that entity will not contain the correct tx$ and it will not be possible to correlate all the actions in a single transactions.

geek commented 8 years ago

@gkubisa please look at #58, does this describe the case you are describing? If not, can you create an test.

gkubisa commented 8 years ago

@geek I added a test which exposes the issue (see #59) and suggested an additional, stricter, test. I think this issue should be reopened.

geek commented 8 years ago

@gkubisa see what you think of the update to the test case... if you change this in the following code to self it works, using the seneca instance in the action context: https://github.com/senecajs/seneca-transport/commit/0f47a312da09882691dda183c509f3913eb2bd70#diff-5fac3a2a0809a391e90c5225331c1714R107

gkubisa commented 8 years ago

@geek Using self like that is really a workaround for that specific case - you used the seneca instance which is not related to the entity. this in the callback of entity.save$ references a different seneca instance which has an incorrect tx$ and that is a problem.

I have updated my test case in #61 to show a situation where using the self workaround would not help, because the implicit role:entity,cmd:save action itself uses the incorrect tx$.