Skip to content

Commit d7df154

Browse files
joeauyeungdevin-ai-integration[bot]Udit-takkar
authored
fix: Add critical logger for booking created log to prevent stdout buffering issues (calcom#24570)
* Add critical logger for booking created log to prevent stdout buffering issues Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * Add comment * Separate critialLogger into it's own file --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
1 parent 51d78e6 commit d7df154

9 files changed

Lines changed: 39 additions & 14 deletions

File tree

apps/web/modules/signup-view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export default function Signup({
313313
id="gtm-init-script"
314314
// It is strictly not necessary to disable, but in a future update of react/no-danger this will error.
315315
// And we don't want it to error here anyways
316-
// eslint-disable-next-line react/no-danger
316+
317317
dangerouslySetInnerHTML={{
318318
__html: `(function (w, d, s, l, i) {
319319
w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
@@ -323,7 +323,7 @@ export default function Signup({
323323
}}
324324
/>
325325
<noscript
326-
// eslint-disable-next-line react/no-danger
326+
327327
dangerouslySetInnerHTML={{
328328
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GTM_ID}" height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
329329
}}

apps/web/playwright/dynamic-booking-pages.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ test.describe("Organization:", () => {
193193
});
194194
await expect(page.getByTestId("success-page")).toBeVisible();
195195
// All the teammates should be in the booking
196-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
196+
197197
await expect(page.getByText(user1.name!, { exact: true })).toBeVisible();
198-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
198+
199199
await expect(page.getByText(user2.name!, { exact: true })).toBeVisible();
200200
}
201201
);

apps/web/playwright/lib/testUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createHash } from "crypto";
44
import EventEmitter from "events";
55
import type { IncomingMessage, ServerResponse } from "http";
66
import { createServer } from "http";
7-
// eslint-disable-next-line no-restricted-imports
7+
88
import type { Messages } from "mailhog";
99
import { totp } from "otplib";
1010
import { v4 as uuid } from "uuid";
@@ -213,7 +213,7 @@ export async function setupManagedEvent({
213213
addManagedEventToTeamMates: true,
214214
managedEventUnlockedFields: unlockedFields,
215215
});
216-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
216+
217217
const memberUser = users.get().find((u) => u.name === teamMateName)!;
218218
const { team } = await adminUser.getFirstTeamMembership();
219219
const managedEvent = await adminUser.getFirstTeamEvent(team.id, SchedulingType.MANAGED);
@@ -365,7 +365,7 @@ async function createUserWithSeatedEvent(users: Fixtures["users"]) {
365365
},
366366
],
367367
});
368-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
368+
369369
const eventType = user.eventTypes.find((e) => e.slug === slug)!;
370370
return { user, eventType };
371371
}

apps/web/playwright/organization/booking.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ test.describe("Bookings", () => {
184184
// Anyone of the teammates could be the Host of the booking.
185185
const chosenUser = await page.getByTestId("booking-host-name").textContent();
186186
expect(chosenUser).not.toBeNull();
187-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
187+
188188
expect(teamMatesObj.concat([{ name: owner.name! }]).some(({ name }) => name === chosenUser)).toBe(
189189
true
190190
);
@@ -248,7 +248,7 @@ test.describe("Bookings", () => {
248248
// Anyone of the teammates could be the Host of the booking.
249249
const chosenUser = await page.getByTestId("booking-host-name").textContent();
250250
expect(chosenUser).not.toBeNull();
251-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
251+
252252
expect(teamMatesObj.concat([{ name: owner.name! }]).some(({ name }) => name === chosenUser)).toBe(
253253
true
254254
);

apps/web/playwright/organization/organization-invitation.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test.describe("Organization", () => {
9090

9191
// This test is already covered by booking.e2e.ts where existing user is invited and his booking links are tested.
9292
// We can re-test here when we want to test some more scenarios.
93-
// eslint-disable-next-line @typescript-eslint/no-empty-function
93+
9494
test("existing user invited to an organization", () => {});
9595

9696
test("nonexisting user invited to a Team inside organization", async ({
@@ -313,7 +313,7 @@ test.describe("Organization", () => {
313313
await page.locator('[data-testid="continue-with-email-button"]').click();
314314
await expect(page.locator('[data-testid="signup-submit-button"]')).toBeVisible();
315315

316-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
316+
317317
await page.locator('input[name="username"]').fill(existingUser.username!);
318318
await page
319319
.locator('input[name="email"]')

packages/features/bookings/lib/service/RegularBookingService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
6767
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
6868
import { HttpError } from "@calcom/lib/http-error";
6969
import logger from "@calcom/lib/logger";
70+
import { criticalLogger } from "@calcom/lib/logger.server";
7071
import { getPiiFreeCalendarEvent, getPiiFreeEventType } from "@calcom/lib/piiFreeData";
7172
import { safeStringify } from "@calcom/lib/safeStringify";
7273
import { getTranslation } from "@calcom/lib/server/i18n";
@@ -1726,7 +1727,7 @@ async function handler(
17261727
await usersRepository.updateLastActiveAt(booking.userId);
17271728
const organizerUserAvailability = availableUsers.find((user) => user.id === booking?.userId);
17281729

1729-
logger.info(`Booking created`, {
1730+
criticalLogger.info(`Booking created`, {
17301731
bookingUid: booking.uid,
17311732
selectedCalendarIds: organizerUser.allSelectedCalendars?.map((c) => c.id) ?? [],
17321733
availabilitySnapshot: organizerUserAvailability?.availabilityData

packages/features/eventtypes/components/locations/Locations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const Locations: React.FC<LocationsProps> = ({
149149
);
150150

151151
useEffect(() => {
152-
if (!!prefillLocation) {
152+
if (prefillLocation) {
153153
const newLocationType = prefillLocation.value;
154154

155155
const canAppendLocation = !validLocations.find((location) => location.type === newLocationType);

packages/lib/logger.server.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import fs from "fs";
2+
3+
import logger from "./logger";
4+
5+
/** This should be used if we want to ensure a log statement is always executed.
6+
*
7+
* This should only be used server side
8+
*/
9+
export const criticalLogger = logger.getSubLogger({
10+
name: "critical",
11+
overwrite: {
12+
transportJSON: (logObj) => {
13+
const logString = JSON.stringify(logObj);
14+
const buffer = Buffer.from(logString + "\n");
15+
16+
try {
17+
fs.writeSync(process.stdout.fd, buffer);
18+
} catch (error) {
19+
console.log(`Critical logger: Failed to write log using fs.writeSync: ${error}`);
20+
console.log(logString);
21+
}
22+
},
23+
},
24+
});

packages/ui/components/form/select/Select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export function SelectWithValidation<
219219
position: "absolute",
220220
}}
221221
value={hiddenInputValue}
222-
// eslint-disable-next-line @typescript-eslint/no-empty-function
222+
223223
onChange={() => {}}
224224
// TODO:Not able to get focus to work
225225
// onFocus={() => selectRef.current?.focus()}

0 commit comments

Comments
 (0)