Skip to content

fix: Make sure if header is set already, it isn't set again#12194

Merged
keithwillcode merged 2 commits intomainfrom
11-02-Make_sure_if_header_is_set_already_it_isnt_set_again
Nov 2, 2023
Merged

fix: Make sure if header is set already, it isn't set again#12194
keithwillcode merged 2 commits intomainfrom
11-02-Make_sure_if_header_is_set_already_it_isnt_set_again

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara commented Nov 2, 2023

What does this PR do?

Fixes the following error. Though as far as I tested, the error arises only when there was already an error in the callback endpoint

Screenshot 2023-11-02 at 10 26 12 AM

In case of zohocalendar, the error was coming when this line was executed https://github.com/calcom/cal.com/blob/0091ecf572c063e899ec664e2e3f6aa6e1c6499c/packages/app-store/zohocalendar/api/callback.ts#L58. It returned a non nullish value causing the bug in defaultResponder.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 2, 2023 5:53am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 2, 2023 5:53am
5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview Nov 2, 2023 5:53am
cal ⬜️ Ignored (Inspect) Visit Preview Nov 2, 2023 5:53am
cal-demo ⬜️ Ignored (Inspect) Visit Preview Nov 2, 2023 5:53am
qa ⬜️ Ignored (Inspect) Visit Preview Nov 2, 2023 5:53am
ui ⬜️ Ignored (Inspect) Visit Preview Nov 2, 2023 5:53am

@hariombalhara
Copy link
Copy Markdown
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 2, 2023

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes!

@zomars zomars added the core area: core, team members only label Nov 2, 2023
@hariombalhara hariombalhara changed the title Make sure if header is set already, it isnt set again fix: Make sure if header is set already, it isn't set again Nov 2, 2023
@hariombalhara hariombalhara force-pushed the 11-02-Make_sure_if_header_is_set_already_it_isnt_set_again branch from f64f6c8 to 0091ecf Compare November 2, 2023 04:50
const result = await f(req, res);
ok = true;
if (result) res.json(result);
if (result && !res.writableEnded) {
Copy link
Copy Markdown
Member Author

@hariombalhara hariombalhara Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be cases where header is already set and result is also set. e.g. res.redirect unlike res.json returns a non nullish value and thus we would endup setting json in that case as well which would cause 'header already set error'

So, we should set this json if something isn't already written to the stream.

Copy link
Copy Markdown
Contributor

@keithwillcode keithwillcode Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find. Unit testable (could be follow up)?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 2, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@hariombalhara hariombalhara marked this pull request as ready for review November 2, 2023 04:58
@deploysentinel
Copy link
Copy Markdown

deploysentinel Bot commented Nov 2, 2023

Current Playwright Test Results Summary

✅ 251 Passing - ⚠️ 8 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 11/02/2023 05:57:01am UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: ff4b6d3

Started: 11/02/2023 05:53:10am UTC

⚠️ Flakes

📄   apps/web/playwright/login.2fa.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
2FA Tests should allow a user to enable 2FA and login using 2FA
Retry 1Initial Attempt
0.39% (1) 1 / 255 run
failed over last 7 days
33.73% (86) 86 / 255 runs
flaked over last 7 days

📄   apps/web/playwright/booking-pages.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
pro user Time slots are not reserved when going back via Cancel button on Event Form
Retry 1Initial Attempt
0.46% (1) 1 / 216 run
failed over last 7 days
0.46% (1) 1 / 216 run
flaked over last 7 days

📄   apps/web/playwright/integrations-stripe.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Stripe integration Can book a paid booking
Retry 1Initial Attempt
2.64% (7) 7 / 265 runs
failed over last 7 days
3.40% (9) 9 / 265 runs
flaked over last 7 days

📄   apps/web/playwright/booking/addressQuestione2e/addressQuestion.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Booking With Address Question and Each Other Question Booking With Address Question and Short text question Address and Short text not required
Retry 1Initial Attempt
0% (0) 0 / 186 runs
failed over last 7 days
2.15% (4) 4 / 186 runs
flaked over last 7 days

📄   apps/web/playwright/event-types.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests user Different Locations Tests Can remove location from multiple locations that are saved
Retry 1Initial Attempt
0% (0) 0 / 253 runs
failed over last 7 days
7.11% (18) 18 / 253 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should open embed iframe on click - Configured with light theme
Retry 1Initial Attempt
2.92% (8) 8 / 274 runs
failed over last 7 days
51.82% (142) 142 / 274 runs
flaked over last 7 days
Popup Tests should be able to reschedule
Retry 2Retry 1Initial Attempt
20.07% (55) 55 / 274 runs
failed over last 7 days
77.01% (211) 211 / 274 runs
flaked over last 7 days

📄   apps/web/playwright/teams.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - NonOrg Can create a private team
Retry 1Initial Attempt
0% (0) 0 / 178 runs
failed over last 7 days
14.61% (26) 26 / 178 runs
flaked over last 7 days

View Detailed Build Results


Copy link
Copy Markdown
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait is the endpoint api/integrations/zoho_calendar or api/integrations/zohocalendar ?

I see api/integrations/zoho_calendar when installing app

Screenshot 2023-11-02 at 5 42 27 PM

const result = await f(req, res);
ok = true;
if (result) res.json(result);
if (result && !res.writableEnded) {
Copy link
Copy Markdown
Contributor

@keithwillcode keithwillcode Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find. Unit testable (could be follow up)?

@keithwillcode keithwillcode merged commit d8356e9 into main Nov 2, 2023
@keithwillcode keithwillcode deleted the 11-02-Make_sure_if_header_is_set_already_it_isnt_set_again branch November 2, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants