Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnknownHTTPResponseError: Request to Notion API failed with status: 502 #457

Open
britonmarketing opened this issue Sep 26, 2023 · 20 comments

Comments

@britonmarketing
Copy link

britonmarketing commented Sep 26, 2023

This one is a duplicate of #172, it occurs for many users and needs to be re-open

Server Error
UnknownHTTPResponseError: Request to Notion API failed with status: 502

This error happened while generating the page. Any console logs will be displayed in the terminal window.

I have about 30 pages, it occurs randomly on a few of them during the build

Console:

Uncaught UnknownHTTPResponseError: Request to Notion API failed with status: 502
at buildRequestError
at Client.request
at process.processTicksAndRejections
at async getProps
at async Object.renderToHTML
at async doRender
at async cacheEntry1.responseCache.get.incrementalCache.incrementalCache
at async

@interpolack
Copy link

thanks for opening. adding my name to the list of people it's happening to

@lailo
Copy link

lailo commented Sep 27, 2023

I've been experiencing this issue for a few days while collecting page data in my Next.js app. It used to occur randomly and only occasionally, but now it happens every time.

@notionhq/client warn: request fail {
   code: 'notionhq_client_response_error',
   message: 'Request to Notion API failed with status: 502'
}

@michalpuchmertl
Copy link

Same for me.

@Badestrand
Copy link

same and from #172 it seems to be a really prevalent issue.

@DZGoldman
Copy link

same - hadn't seen this error before but now hitting it consistently

@AlAgilly
Copy link

Same. It even occurs for just reading small databases (~15 pages). It's reoccurring at an increasing amount the past week..
Error:

@notionhq/client warn: request fail {
  code: 'notionhq_client_response_error',
  message: 'Request to Notion API failed with status: 502'
}

My code can be found here:
https://github.com/AlAgilly/yues_website/blob/main/server/index.js

Willing to give access to my databases if needed

@stensrud
Copy link

I'm getting the same problem

@lakeesiv
Copy link

Im also getting this aswell

@accounts01
Copy link

+1. I'm experiencing this as well.

@BenMt
Copy link

BenMt commented Sep 28, 2023

+1

1 similar comment
@juanicortesl
Copy link

+1

@ziegfried
Copy link

ziegfried commented Sep 29, 2023

The main problem here is that the notion client holds on to the connection and once it hits a 502 error, every subsequent request also results in such an error. Even creating a new notion client instance doesn't solve the issue (it uses the same http agent instance).

Our current workaround:

  • Create notion client with it's own agent
  • When experiencing the 502 error we create a new notion client instance along with a new http agent

Something along the lines:

import { Agent } from "https";
import { Client } from "@notionhq/client";

let agent, notion;

function reset() {
    if (agent) agent.destroy();
    agent = new Agent();
    notion = new Client({ auth: process.env.NOTION_TOKEN, agent });
}

reset();

// Using the notion client:
try {
    // do something with notion client
} catch(e) {
    const errorText = e.toString();
    if (
      errorText.includes("PgPoolWaitConnectionTimeout") ||
      errorText.includes("Request timed out") ||
      errorText.includes("Request to Notion API has timed out") ||
      errorText.includes("Request to Notion API failed with status: 502")
    ) {
      reset();
    }
}

@Badestrand
Copy link

I now also get the error

@notionhq/client warn: request fail {
  code: 'service_unavailable',
  message: 'Request timed out waiting to connect to a database. Please try again later.'
}

sometimes.

@TopherTimeMachine
Copy link

I just starting getting this message while trying to create a page. It was working a few days ago.

@notionhq/client warn: request fail {
  code: 'notionhq_client_request_timeout',
  message: 'Request to Notion API has timed out'
}

I tried the reset() solution above and didn't seem to work. What other options are there? Notion support or dev team listening in?

@pulbee
Copy link

pulbee commented Oct 4, 2023

I am getting both these errors, almost 50% of time while GET:/ notion page, While updating a notion page, While querying a Notion database.

@notionhq/client warn: request fail {
 code: 'notionhq_client_request_timeout',
 message: 'Request to Notion API has timed out'
}

@notionhq/client warn: request fail {
 code: 'notionhq_client_response_error',
 message: 'Request to Notion API failed with status: 502'
}

Although retrying works, But It's still not viable solution and Notion API has almost become unreliable recently.

NodeJs version : 20
@notionhq/client": "^2.2.7"

@remihuigen
Copy link

remihuigen commented Oct 4, 2023

Same here! Just contacted support, since i don't think they are gonna respond to this github issue. Will post update if I get a response

@Smidgens
Copy link

Smidgens commented Oct 6, 2023

I'm still getting this occasionally on reads, with no discernible pattern (reads of any size, random hours...). My workaround is to simply catch the error and retry. So far I think it's always succeeded on the second try but...

It would be great if Notion either added a mention of 502s to the API docs, or silently handled the error in the SDK (make it an opt-in flag even).

@remihuigen
Copy link

Same here! Just contacted support, since i don't think they are gonna respond to this github issue. Will post update if I get a response

Just got a reply from support:

I can understand how important this is for you and the inconvenience this created to your workflow.
 
In the last couple of days, Notion and API experienced incidents with degraded performance. I'm happy to inform you that this has now been resolved!
 
You should be good to go! :)

In the last 24 hours I've only occasionally encountered 502s, but they are still popping up now and then. I also don't buy Notion supports claim that it has been 'an issue in the last couple of days' and that it should be resolved now. Since as far as I can tell the 502s have been happening for over two weeks.

Anyway, I believe they are still not willing to acknowledge the shabby state of their public API, and we should not except any improvements soon. My conclusion is that their API is fun for internal projects, but not production ready anytime soon.

I've implemented a workaround where the app retries fetching the API if the response is a 502, with a max of 5 retries. So far I haven't needed the fifth retry.

@linkyndy
Copy link

Same issue here, only that every requests times out or takes >20s to respond. Basically, we cannot use the API. And we haven't heard back on any of our tickets on any of the support channels about this.

@DerickIT
Copy link

I still have this problem. Can I solve it in other ways?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests