pyright-playground icon indicating copy to clipboard operation
pyright-playground copied to clipboard

Becomes unresponsive after a few dozen edits

Open dimaqq opened this issue 1 year ago • 8 comments

I think I'm able to overload the server alone, using a single tab.

I'd start with some code, and keep editing (in my case: an xp session over a video call).

I think what happens is that the ui tries to get something from the backend that seems to overload the latter.

When it's stuck like that, trying to reload the page doesn't get me anywhere -- the page ui doesn't even load.

Here's a screenie when it's pretty stuck, but not fatal yet:

dimaqq avatar Apr 18 '25 00:04 dimaqq

Image

dimaqq avatar Apr 18 '25 00:04 dimaqq

P.S. thank you making this tool public, it's so much easier to share (application) typing work with others asynchronously!

dimaqq avatar Apr 18 '25 00:04 dimaqq

Btw., some requests fail after 4 minutes:

Request URL:
https://pyright-playground.azurewebsites.net/api/session
Request Method:
POST
Status Code:
504 Gateway Timeout
Referrer Policy:
strict-origin-when-cross-origin

dimaqq avatar Apr 18 '25 00:04 dimaqq

Rarely there's an actual error:

Request URL:
https://pyright-playground.azurewebsites.net/api/session/275cfdb8-c9df-4eaa-a65b-76aec422c444/diagnostics
Request Method:
POST
Status Code:
500 Internal Server Error
Remote Address:
40.64.128.226:443
Referrer Policy:
strict-origin-when-cross-origin
access-control-allow-origin:
https://pyright-play.net
content-length:
14
content-type:
application/json; charset=utf-8
date:
Fri, 18 Apr 2025 00:04:19 GMT
etag:
W/"e-WzibJtRR8IBMD+72ymDOMG90dCQ"
request-context:
appId=cid-v1:
vary:
Origin
x-powered-by:
Express

dimaqq avatar Apr 18 '25 00:04 dimaqq

A possible compounding factor is that when the backend is overloaded, the error response arrives without the CORS header, which means that it's invisible to the javascript on the page:

Access to fetch at 'https://pyright-playground.azurewebsites.net/api/session' from origin 'https://pyright-play.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I think this could be worked around in the load balancer settings. If it's an Azure CDN, then that would be endpoint resource -> rules engine -> add rule? I had once set something like this up and specifically had to add CORS bits for the case when the API server fails entirely.

dimaqq avatar Apr 18 '25 00:04 dimaqq

Yes, this is hosted on Azure. I personally pay for it, and it costs me about $600 a year currently. The hosting plan I'm using is relatively limited, and I'm not inclined to scale it out further without a source of outside funding. The tool has become pretty popular, which explains why it's probably hitting some of these rate limits. If you'd like to sponsor the hosting, let me know.

erictraut avatar Apr 18 '25 00:04 erictraut

My point was that the UI issued too many requests to the backend.

And then when things got slow, the UI didn't not feel the back pressure and continued issuing even more requests.

P.S. I kinda wish your employer could cough up a limited free plan... I mean it's your work and your company advocacy.

That being said, my employer has recently started sponsoring libraries and tools we depend on, via https://thanks.dev

  • https://www.linkedin.com/posts/chadwhitacre_awesome-to-see-canonical-join-us-on-thanksdev-activity-7316096570347651073-M09z
  • https://thanks.dev/d/gh/canonical/dependencies

It's not much, but I hope sets a good example.

dimaqq avatar Apr 18 '25 00:04 dimaqq

I kinda wish your employer could cough up a limited free plan

I don't have an employer. I previously worked for Microsoft, but I haven't worked for them for the past couple of years. Even when I was working at Microsoft, pyright was a side project. Since leaving the company, I've continued to maintain pyright on my own time for the benefit of the Python community.

I previously asked the director of the pylance team if he'd be willing to pay for the pyright playground hosting, but I didn't get an answer back from him, which I took that as a "no".

erictraut avatar Apr 18 '25 01:04 erictraut