From 695d51b9f665b7d5e15ad2752f8a799c1295da3d Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Tue, 18 Jan 2022 11:22:56 +0100 Subject: [PATCH] fix: replace Meteor.default_server with Meteor.server Meteor.default_server was undocumented, and finally removed in Meteor 2.3 --- __tests__/methodsInstrument.js | 14 +++++++------- __tests__/mocks/meteor.js | 6 +++--- instrumenting/methods.js | 2 +- meteorx.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/__tests__/methodsInstrument.js b/__tests__/methodsInstrument.js index edc3909..e46c29f 100644 --- a/__tests__/methodsInstrument.js +++ b/__tests__/methodsInstrument.js @@ -27,12 +27,12 @@ test('close transaction with method result', () => { } }); - Meteor.default_server.method_handlers.method1(); + Meteor.server.method_handlers.method1(); expect(agent.currentTransaction.end.mock.calls.length).toBe(1); expect(agent.currentTransaction.end.mock.calls[0][0]).toBe('success'); - Meteor.default_server.method_handlers.method2(); + Meteor.server.method_handlers.method2(); expect(agent.currentTransaction.end.mock.calls.length).toBe(2); expect(agent.currentTransaction.end.mock.calls[1][0]).toBe('success'); @@ -51,7 +51,7 @@ test('ignore if transaction is undefined', () => { instrumentMethods(agent, Meteor); - Meteor.default_server.method_handlers.method1(); + Meteor.server.method_handlers.method1(); }); test('close transaction and its span with method result', () => { @@ -79,7 +79,7 @@ test('close transaction and its span with method result', () => { } }); - Meteor.default_server.method_handlers.method1(); + Meteor.server.method_handlers.method1(); expect(agent.currentTransaction.end.mock.calls.length).toBe(1); expect(agent.currentTransaction.end.mock.calls[0][0]).toBe('success'); @@ -113,14 +113,14 @@ test('catch meteor method exception', () => { }); expect(() => { - Meteor.default_server.method_handlers.method1(); + Meteor.server.method_handlers.method1(); }).toThrow(); expect(agent.captureError.mock.calls.length).toBe(1); expect(agent.captureError.mock.calls[0][0].message).toBe('Test error 1'); expect(() => { - Meteor.default_server.method_handlers.method2(); + Meteor.server.method_handlers.method2(); }).toThrow(); expect(agent.captureError.mock.calls.length).toBe(2); @@ -148,7 +148,7 @@ test('transform string exception into Error object', () => { instrumentMethods(agent, Meteor); expect(() => { - Meteor.default_server.method_handlers.textError(); + Meteor.server.method_handlers.textError(); }).toThrow(); expect(agent.captureError.mock.calls.length).toBe(1); diff --git a/__tests__/mocks/meteor.js b/__tests__/mocks/meteor.js index 8ee7303..958d465 100644 --- a/__tests__/mocks/meteor.js +++ b/__tests__/mocks/meteor.js @@ -15,12 +15,12 @@ function newMeteor() { publish: jest.fn(), Collection, methods(methodsMap) { - this.default_server.method_handlers = { - ...this.default_server.method_handlers, + this.server.method_handlers = { + ...this.server.method_handlers, ...methodsMap }; }, - default_server: { + server: { method_handlers: {} } }; diff --git a/instrumenting/methods.js b/instrumenting/methods.js index 0b34c50..efc310e 100644 --- a/instrumenting/methods.js +++ b/instrumenting/methods.js @@ -52,7 +52,7 @@ function start(agent, Meteor) { }); } - const methodHandlers = Meteor.default_server.method_handlers; + const methodHandlers = Meteor.server.method_handlers; Object.keys(methodHandlers).forEach(methodName => wrapMethods(methodName, methodHandlers)); shimmer.wrap(Meteor, 'methods', function(original) { diff --git a/meteorx.js b/meteorx.js index 93a9aed..6ecfc78 100644 --- a/meteorx.js +++ b/meteorx.js @@ -11,7 +11,7 @@ function getSession() { headers: [] }; - const server = Meteor.default_server; + const server = Meteor.server; server._handleConnect(fakeSocket, { msg: 'connect',