Skip to content

Commit 5106085

Browse files
authored
fix: Call context.toJSON if available (#185)
1 parent 462eae9 commit 5106085

File tree

8 files changed

+4878
-2277
lines changed

8 files changed

+4878
-2277
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
node-version: [12.x, 16.x]
8+
node-version: [14.x, 18.x]
99
steps:
10-
- uses: actions/checkout@v2
11-
- name: Use Node.js ${{ matrix.node-version }}
12-
uses: actions/setup-node@v1
13-
with:
14-
node-version: ${{ matrix.node-version }}
15-
- name: Start Redis
16-
uses: supercharge/redis-github-action@1.1.0
17-
with:
18-
redis-version: '5'
19-
- name: Setup Rabbitmq
20-
uses: nijel/rabbitmq-action@v1.0.0
21-
- name: Setup NATS
22-
run: |
23-
wget https://github.com/nats-io/nats-server/releases/download/v2.0.0/nats-server-v2.0.0-linux-amd64.zip
24-
unzip nats-server-v2.0.0-linux-amd64.zip
25-
nats-server-v2.0.0-linux-amd64/nats-server </dev/null &>/dev/null &
26-
- run: sleep 30
27-
- run: npm ci
28-
- run: npm test
10+
- uses: actions/checkout@v2
11+
- name: Use Node.js ${{ matrix.node-version }}
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: ${{ matrix.node-version }}
15+
- name: Start Redis
16+
uses: supercharge/redis-github-action@1.1.0
17+
with:
18+
redis-version: "5"
19+
- name: Setup Rabbitmq
20+
uses: nijel/rabbitmq-action@v1.0.0
21+
- name: Setup NATS
22+
run: |
23+
wget https://github.com/nats-io/nats-server/releases/download/v2.0.0/nats-server-v2.0.0-linux-amd64.zip
24+
unzip nats-server-v2.0.0-linux-amd64.zip
25+
nats-server-v2.0.0-linux-amd64/nats-server </dev/null &>/dev/null &
26+
- run: sleep 30
27+
- run: npm ci
28+
- run: npm test

lib/core.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ module.exports = app => {
5252
return this._emit(event, data, ctx);
5353
}
5454

55+
const serializedContext = typeof ctx.toJSON === 'function' ? ctx.toJSON() : ctx;
5556
const context = ctx && (ctx.app === app || ctx.service === service)
56-
? _.omit(ctx, 'app', 'service', 'self')
57-
: ctx;
57+
? _.omit(serializedContext, 'app', 'service', 'self')
58+
: serializedContext;
5859

5960
debug(`Sending sync-out event '${path} ${event}'`);
6061

0 commit comments

Comments
 (0)