This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.on('beforeExit', () => invokeManager.finish(null, null, false)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InvokeManager { | |
finish(err, data, waitToFinish) { | |
if (this._result === undefined) { | |
if (err == null) { | |
this._result = [null, JSON.stringify(isUndefined(data) ? null : data)]; | |
} else { | |
let errType = this._faulted ? 'unhandled' : 'handled'; | |
this._result = [errType, stringifyError(errType, err)]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export.handler = function (evt, ctx, callback) { | |
Promise.resolve() | |
.then(() => { | |
// Unmodified handler execution | |
}) | |
.then(koaResponse => { | |
// Unmodified success handling | |
}) | |
.catch(e => { | |
if (!e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export.handler = function (evt, ctx, callback) { | |
Promise.resolve() | |
.then(() => { | |
const koaRequest = convertToKoaRequest() | |
return myAppResponseHandler(koaRequest); | |
}) | |
.then(koaResponse => { | |
callback(null, { | |
statusCode: koaResponse.statusCode | |
headers: getHeaders(koaResponse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const result = await lambda.invoke(request).promise(); | |
const payload = JSON.parse(result.Payload); | |
const body = payload.body; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.returnNull = function (event, context, callback) { | |
callback(null, null); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_lambda_function" "service" { | |
# Your usual aws_lambda_function configuration settings here | |
tracing_config { | |
mode = "Active" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const traceResolvers = require('@lifeomic/graphql-resolvers-xray-tracing'); | |
const schema = makeExecutableSchema( ... ); | |
traceResolvers(schema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xray = require('aws-xray-sdk-core'); | |
// Allow X-Ray to track execution through API API calls | |
xray.captureAWS(require('aws-sdk')); | |
// Allow X-Ray to track execution through external API calls | |
xray.captureHTTPsGlobal(require('http')); | |
// Allow X-Ray to track execution when Promises are used | |
xray.capturePromise(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const memwatch = require('memwatch-next'); | |
const _ = require('lodash'); | |
const zlib = require('./lib/zlib'); | |
function writeLeakDiff(diff) { | |
const closures = _.filter(diff.change.details, {what: 'Closure'}); | |
console.log('Closure changes', closures); | |
const buffers = _.filter(diff.change.details, {what: 'Uint8Array'}); | |
console.log('Uint8Array changes', buffers); |