Skip to content

Commit

Permalink
relay should run at 128mb
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Jul 25, 2023
1 parent 39ab04b commit 42844bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/commands/local/lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ async function updateFunctions(func, lambdaClient) {
const updateFunctionConfigurationCommand = new UpdateFunctionConfigurationCommand({
FunctionName: functionName,
Timeout: parseInt(process.env.SAMP_TIMEOUT || 60),
MemorySize: 256,
MemorySize: 128,
Handler: 'relay.handler',
});
await lambdaClient.send(updateFunctionConfigurationCommand);
Expand Down
17 changes: 15 additions & 2 deletions src/commands/local/lib/relay/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,21 @@ export const handler = async (event, context) => {
};

function publishEvent(event, context) {
const sessionId = new Date().getTime() + '-' + Math.floor((Math.random() * 1000000) + 1); // Unique ID for this debug session
const sessionId = new Date().getTime() + '-' + Math.floor((Math.random() * 1000000) + 1); // Unique ID for this rounndtrip
const totalPayload = JSON.stringify({ event, context, envVars: process.env, sessionId });
if (totalPayload.length > 64) {
const chunks = totalPayload.match(/.{1,64}/g);
chunks.forEach((chunk, index) => {
const payload = JSON.stringify({ event: 'chunk', chunk, index, totalChunks: chunks.length });
publish(payload, sessionId);
});
} else {
publish(totalPayload, sessionId);
}
}

function publish(payload, sessionId) {
client.subscribe(`lambda-debug/callback/${config.mac}/${sessionId}`);
client.publish('lambda-debug/event/' + config.mac, JSON.stringify({ event, context, envVars: process.env, sessionId }));
client.publish('lambda-debug/event/' + config.mac, payload);
}

0 comments on commit 42844bd

Please sign in to comment.