Skip to content

Commit

Permalink
remove excesive logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goodwin committed Jan 2, 2024
1 parent 9de3599 commit 3100267
Show file tree
Hide file tree
Showing 37 changed files with 301 additions and 225 deletions.
1 change: 0 additions & 1 deletion apps/test-app-runtime/src/my-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { task, workflow } from "@eventual/core";

export default workflow("my-workflow", async ({ name }: { name: string }) => {
const result = await Promise.all([hello(name), hello2(name)]);
console.log(result);
const result2 = await hello(name);
return `you said ${result2} ${result}`;
});
Expand Down
6 changes: 1 addition & 5 deletions apps/test-app-runtime/src/parent-child-com.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const workflow1 = workflow("workflow1", async () => {
while (true) {
const n = await mySignal.expectSignal();

console.log(n);

if (n > 10) {
child.sendSignal(doneSignal);
break;
Expand All @@ -32,7 +30,7 @@ export const workflow1 = workflow("workflow1", async () => {
*/
export const workflow2 = workflow(
"workflow2",
async (input: { name: string }, { execution: { parentId } }) => {
async (_input: { name: string }, { execution: { parentId } }) => {
let block = false;
let done = false;
let last = 0;
Expand All @@ -41,8 +39,6 @@ export const workflow2 = workflow(
throw new Error("I need an adult");
}

console.log(`Hi, I am ${input.name}`);

mySignal.onSignal((n) => {
last = n;
block = false;
Expand Down
4 changes: 1 addition & 3 deletions apps/test-app-sst/services/functions/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ api.post("/work", async (request) => {
});

export const myWorkflow = workflow("myWorkflow", async (items: string[]) => {
const results = await Promise.all(items.map(doWork));
const results = await Promise.all(items.map((item) => doWork(item)));

await workDone.emit({
outputs: results,
Expand All @@ -23,8 +23,6 @@ export const myWorkflow = workflow("myWorkflow", async (items: string[]) => {
});

export const doWork = task("work", async (work: string) => {
console.log("Doing Work", work);

return work.length;
});

Expand Down
33 changes: 15 additions & 18 deletions apps/tests/aws-runtime/test/async-writer-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ export interface AsyncWriterTestEvent {
}

export const handle: Handler<AsyncWriterTestEvent[], void> = async (event) => {
console.log(event);
console.log(
await Promise.allSettled(
event.map(async (e) => {
if (e.type === "complete") {
await serviceClient.sendTaskSuccess({
taskToken: e.token,
result: "hello from the async writer!",
});
} else {
await serviceClient.sendTaskFailure({
taskToken: e.token,
error: "AsyncWriterError",
message: "I was told to fail this task, sorry.",
});
}
})
)
await Promise.allSettled(
event.map(async (e) => {
if (e.type === "complete") {
await serviceClient.sendTaskSuccess({
taskToken: e.token,
result: "hello from the async writer!",
});
} else {
await serviceClient.sendTaskFailure({
taskToken: e.token,
error: "AsyncWriterError",
message: "I was told to fail this task, sorry.",
});
}
})
);
};
1 change: 0 additions & 1 deletion apps/tests/aws-runtime/test/runtime-test-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ export async function waitForWorkflowCompletion<W extends Workflow = Workflow>(
if (!execution) {
throw new Error("Cannot find execution id: " + executionId);
}
console.log(JSON.stringify(execution, null, 4));
if (
execution.status === ExecutionStatus.IN_PROGRESS &&
!(cancelCallback?.() ?? false)
Expand Down
25 changes: 2 additions & 23 deletions apps/tests/aws-runtime/test/test-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const asyncTask = task(
"asyncTask",
async (type: AsyncWriterTestEvent["type"]) => {
return asyncResult<string>(async (token) => {
console.log(testQueueUrl);
if (!process.env.EVENTUAL_LOCAL) {
await sqs.send(
new SendMessageCommand({
Expand Down Expand Up @@ -109,9 +108,7 @@ const fail = task("fail", async (value: string) => {
export const workflow1 = workflow(
"my-workflow",
async ({ name }: { name: string }) => {
console.log("before");
const result = await hello2(name);
console.log("after");
return `you said ${result}`;
}
);
Expand Down Expand Up @@ -159,8 +156,6 @@ export const parentWorkflow = workflow("parentWorkflow", async () => {
while (true) {
const n = await mySignal.expectSignal({ timeout: duration(10, "seconds") });

console.log(n);

if (n > 10) {
child.sendSignal(doneSignal);
break;
Expand Down Expand Up @@ -189,8 +184,6 @@ export const childWorkflow = workflow(
throw new Error("I need an adult");
}

console.log(`Hi, I am ${input.name}`);

mySignal.onSignal((n) => {
last = n;
block = false;
Expand Down Expand Up @@ -414,7 +407,6 @@ export const onSignalEvent = subscription(
events: [signalEvent],
},
async ({ executionId, signalId, proxy }) => {
console.debug("received signal event", { executionId, signalId, proxy });
if (proxy) {
// if configured to proxy, re-route this event through the signalEvent
// reason: to test that we can emit events from within an event handler
Expand Down Expand Up @@ -618,7 +610,6 @@ export const counterWatcher = counter.stream(
"counterWatcher",
{ operations: ["modify", "remove"], includeOld: true },
async (item) => {
console.log(item);
if (item.operation === "remove") {
const { n } = item.oldValue!;
await entitySignal2.sendSignal(item.key.id, { n: n + 1 });
Expand All @@ -635,15 +626,13 @@ export const counterNamespaceWatcher = counter.batchStream(
async (items) => {
await Promise.all(
items.map(async (item) => {
console.log(item);
const value = await counter.get(item.key);
await counter.put({
namespace: "default",
id: value!.id,
n: (value?.n ?? 0) + 1,
optional: undefined,
});
console.log("send signal to", value!.id);
await entitySignal.sendSignal(value!.id);
})
);
Expand Down Expand Up @@ -786,7 +775,6 @@ export const entityWorkflow = workflow(
// and then validate the order value against the final value at the end.
entityOrderSignal.onSignal(({ n }) => {
if (n > orderValue) {
console.log(`Ordered Value: ${orderValue} ${n}`);
orderValue = n;
} else {
orderError = `order value ${n} is less than or equal to previous value ${orderValue}, the stream handler executed out of order!`;
Expand Down Expand Up @@ -986,12 +974,10 @@ const noise = task(
throw err;
}
}
console.log(n);
if (n === x) {
transact = gitErDone({ id });
}
}
console.log("waiting...");
try {
return await transact;
} catch (err) {
Expand Down Expand Up @@ -1332,9 +1318,8 @@ const simpleEvent = event<{ value: string }>("simpleEvent");
export const simpleEventHandler = subscription(
"simpleEventHandler",
{ events: [simpleEvent] },
(payload) => {
console.log("hi", payload);
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
(_payload) => {}
);

export const blogIndex = index("blogIndex", {
Expand Down Expand Up @@ -1421,13 +1406,11 @@ export interface SocketMessage {

const jsonSocket = socket.use({
message: ({ request: { body }, context, next }) => {
console.log(body);
const data = body
? body instanceof Buffer
? (JSON.parse(body.toString("utf-8")) as SocketMessage)
: (JSON.parse(body) as SocketMessage)
: undefined;
console.log("data", data);
if (!data) {
throw new Error("Expected data");
}
Expand All @@ -1445,24 +1428,20 @@ export const socket1 = jsonSocket
})
.socket("socket1", {
$connect: async ({ connectionId }, { id, n }) => {
console.log("sending signal to", id);
await socketConnectSignal.sendSignal(id, {
connectionId,
n: Number(n),
});
console.log("signal sent to", id);
},
$disconnect: async () => undefined,
$default: async ({ connectionId }, { data }) => {
if (!data.id) {
throw new Error("Invalid id");
}
console.log("sending signal to", data.id);
await socketMessageSignal.sendSignal(data.id, {
...data,
connectionId,
});
console.log("signal sent to", data.id);
},
});

Expand Down
11 changes: 0 additions & 11 deletions apps/tests/aws-runtime/test/tester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,12 @@ test("socket test", async () => {

const encodedId = encodeURIComponent(executionId);

console.log("pre-socket");

const ws1 = new WebSocket(`${socketUrl}?id=${encodedId}&n=0`);
const ws2 = new WebSocket(`${socketUrl}?id=${encodedId}&n=1`);

console.log("setup-socket");

const running1 = setupWS(executionId, ws1);
const running2 = setupWS(executionId, ws2);

console.log("waiting...");

const result = await Promise.all([running1, running2]);

expect(result).toEqual([3, 4]);
Expand All @@ -480,7 +474,6 @@ function setupWS(executionId: string, ws: WebSocket) {
let v: number | undefined;
return new Promise<number>((resolve, reject) => {
ws.on("error", (err) => {
console.log("error", err);
reject(err);
});
ws.on("message", (data) => {
Expand All @@ -493,9 +486,7 @@ function setupWS(executionId: string, ws: WebSocket) {
);

try {
console.log(n, "message");
const d = (data as Buffer).toString("utf8");
console.log(d);
const event = JSON.parse(d) as StartSocketEvent | DataSocketEvent;
if (event.type === "start") {
n = event.n;
Expand All @@ -516,8 +507,6 @@ function setupWS(executionId: string, ws: WebSocket) {
});
ws.on("close", (code, reason) => {
try {
console.log(code, reason.toString("utf-8"));
console.log(n, "close", v);
if (n === undefined) {
throw new Error("n was not set");
}
Expand Down
3 changes: 0 additions & 3 deletions packages/@eventual/aws-runtime/src/clients/event-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export class AWSEventClient implements EventClient {
): Promise<void> {
const self = this;

console.debug("emit", events);

const eventBatches = chunkArray(
10,
events.map((event, i) => {
Expand Down Expand Up @@ -106,7 +104,6 @@ export class AWSEventClient implements EventClient {

async function retry(events: EventTuple[] | readonly EventTuple[]) {
const delayTime = Math.min(retryConfig.maxDelay, retryConfig.delayMs);
console.debug(`Retrying after waiting ${delayTime}ms`);

await new Promise((resolve) => setTimeout(resolve, delayTime));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class AWSOpenSearchClient implements OpenSearchClient {
credentials: any;
region: string;
}) {
console.log("Open Search endpoint: ", node);
this.client = new Client({
node,
Connection: class extends Connection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class AWSTransactionClient implements TransactionClient {
public async executeTransaction(
request: ExecuteTransactionRequest
): Promise<ExecuteTransactionResponse> {
console.debug("Invoking Transaction: ", request.transaction);
const response = await this.props.lambda.send(
new InvokeCommand({
FunctionName: getLazy(this.props.transactionWorkerFunctionArn),
Expand All @@ -36,8 +35,6 @@ export class AWSTransactionClient implements TransactionClient {
throw new Error("Invalid response from the transaction worker");
}

console.debug("Transaction Complete: ", request.transaction);

return JSON.parse(
Buffer.from(response.Payload).toString("utf-8")
) as ExecuteTransactionResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export function createApiGCommandWorker({
return async function (
event: APIGatewayProxyEventV2
): Promise<APIGatewayProxyResultV2> {
console.debug("event", event);

const serviceUrl = `https://${event.requestContext.domainName}`;
const serviceClient = serviceClientBuilder
? serviceClientBuilder(serviceUrl)
Expand Down Expand Up @@ -96,7 +94,6 @@ export function createApiGCommandWorker({
body: responseBody.toString("base64"),
isBase64Encoded: true,
};
console.debug("httpResponse", httpResponse);
return httpResponse;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const worker = createBucketNotificationHandlerWorker({

export default (async (event) => {
const records = event.Records;
console.debug("records", JSON.stringify(records, undefined, 4));

const results = await promiseAllSettledPartitioned(
records,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const worker = createEntityStreamWorker({

export default (async (event) => {
const records = event.Records;
console.log("records", JSON.stringify(records, undefined, 4));

const items = records.flatMap((record) => {
const operation = record.eventName?.toLowerCase() as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const endpoint = process.env.OS_ENDPOINT;
let client: Client;

export const handle: CloudFormationCustomResourceHandler = async (event) => {
console.log(event);
console.log(JSON.stringify(event));
client ??= await (async () => {
const credentials = await defaultProvider()();
return new Client({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const processEvent = createSubscriptionWorker({
});

export default async function (event: EventBridgeEvent<string, any>) {
console.debug("received", event);
await processEvent([
{
name: event["detail-type"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface ErrorHandlerRequest {
}

export default async (lambdaRequest: ErrorHandlerRequest) => {
console.log("Received fallback to request: " + JSON.stringify(lambdaRequest));
try {
const parsed = JSON.parse(
lambdaRequest.responsePayload.errorMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const handleTimer = createTimerHandler({
});

export const handle: SQSHandler = async (event) => {
console.debug(JSON.stringify(event));
const results = await promiseAllSettledPartitioned(event.Records, (record) =>
handleTimer(JSON.parse(record.body) as TimerRequest)
);
Expand Down
Loading

0 comments on commit 3100267

Please sign in to comment.