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

fix: /api/v1/instance #363

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

DataDrivenMD
Copy link
Contributor

@DataDrivenMD DataDrivenMD commented Mar 2, 2023

Taken together, this PR will improve compatibility with 3rd-party apps, including IceCubes and Ivory

Relevant issues:

cc @xtuc @dario-piotrowicz: could either of you please take a look at this PR?

…tials-endpoint

Fix missing apps verify credentials endpoint
[X] Use the official Mastodon default image for avatar
Change Default Images to Official Mastodon Avatar
This reverts commit 0776114, reversing
changes made to 4ef9d98.
@DataDrivenMD
Copy link
Contributor Author

@dario-piotrowicz Every playwright test from seo.spec.ts is failing but it's not clear to me why that's happening since I didn't touch the front-end code in this PR. Separately, I'm getting 4-6 playwright failures that don't seem to have any discernible reason-- when I manually follow the tests, the results are as expected; so, the assertions are failing prematurely.

Is there another branch that I should be using as the base for this PR?

cc @xtuc

@DataDrivenMD
Copy link
Contributor Author

So, I reverted all the changes in this PR, updated from cloudflare/wildebeest/main and then re-ran the playwright tests, and 6 tests still failed. Then, I manually checked one of the failing tests, and the page rendered correctly. So, it seems that there's something wrong with the playwright configuration (perhaps the timeout period is too short?).

cc @xtuc @dario-piotrowicz

playwright_failing

manual_validation

@DataDrivenMD
Copy link
Contributor Author

Update: I fixed the problem by adjusting Playwright timeouts...and that surfaced an uncaught exception in my code, which I fixed.

backend/src/types/env.ts Outdated Show resolved Hide resolved
config/versions.ts Outdated Show resolved Hide resolved
functions/api/v1/instance.ts Outdated Show resolved Hide resolved
functions/api/v1/instance.ts Outdated Show resolved Hide resolved
backend/src/types/env.ts Outdated Show resolved Hide resolved
functions/api/v1/instance.ts Outdated Show resolved Hide resolved
@dario-piotrowicz
Copy link
Member

@DataDrivenMD I'm so sorry I didn't manage to reply earlier 🙇


Regarding SEO, it should work on main, is your branch up to date with main? and/or have you solved the issue?


Regarding increasing the timeouts I really am not a big fan of that because the current timeouts were working just fine so if you need to increase them it would suggest that our code is getting slower or something like that (also they were longer at some point but it was getting annoying that we'd have to wait a while to see if they would fail so I did shorten the timeouts)

and that surfaced an uncaught exception in my code, which I fixed. 👈 I am not really sure how longer timeouts would surfaced the issue, can you tell me? 🙂
(and regarding this, before increasing the timeouts, have you tried viewing the remote playwright reports? didn't that help?)

@DataDrivenMD
Copy link
Contributor Author

@DataDrivenMD I'm so sorry I didn't manage to reply earlier 🙇

No worries! Thanks for closing the loop.

and that surfaced an uncaught exception in my code, which I fixed. 👈 I am not really sure how longer timeouts would surfaced the issue, can you tell me? 🙂 (and regarding this, before increasing the timeouts, have you tried viewing the remote playwright reports? didn't that help?)

Prior to extending the timeouts I would see different e2e tests fail with every run (i.e. every time I called yarn playwright test). Without changing a single line of code, I ran the tests several times: sometimes 50+ tests would fail, sometimes 30-40, then 26, then 56. It was all over the place, and the tests in seo.spec.ts wouldn't always fail as a group.

Once I extended the timeout period, the playwright tests defined in other files (i.e. not seo.spec.ts were able to run completion (and PASS). Then, and only then, was I able to get consistent results between runs: all of the tests in seo.spec.ts began failing as group in a repeatable manner. That's what I mean by "surfaced an uncaught exception in my code".

IOW: the e2e tests were working as designed but the short timeout period triggered some of them to fail prematurely in a flaky manner. This, in turn, made it impossible to figure out whether the tests were failing due a bug in my code vs. failing due to resource constraints vs. some other reason. Once the timeout period was extended, it was possible to see that a) there was an actual bug in the code and b) trace the exception. The timeout issue is fixed in PR #375, which has now been merged to main

PS - Sorry for the confusion, and I hope my answer clarifies the issue

@DataDrivenMD
Copy link
Contributor Author

@xtuc Just want to flag that this PR is ready for re-review. I left two comments unresolved but added explanations for the proposed changes.

functions/api/v2/instance.ts Outdated Show resolved Hide resolved
@dario-piotrowicz
Copy link
Member

@DataDrivenMD I'm so sorry I didn't manage to reply earlier 🙇

No worries! Thanks for closing the loop.

and that surfaced an uncaught exception in my code, which I fixed. 👈 I am not really sure how longer timeouts would surfaced the issue, can you tell me? 🙂 (and regarding this, before increasing the timeouts, have you tried viewing the remote playwright reports? didn't that help?)

Prior to extending the timeouts I would see different e2e tests fail with every run (i.e. every time I called yarn playwright test). Without changing a single line of code, I ran the tests several times: sometimes 50+ tests would fail, sometimes 30-40, then 26, then 56. It was all over the place, and the tests in seo.spec.ts wouldn't always fail as a group.

Once I extended the timeout period, the playwright tests defined in other files (i.e. not seo.spec.ts were able to run completion (and PASS). Then, and only then, was I able to get consistent results between runs: all of the tests in seo.spec.ts began failing as group in a repeatable manner. That's what I mean by "surfaced an uncaught exception in my code".

IOW: the e2e tests were working as designed but the short timeout period triggered some of them to fail prematurely in a flaky manner. This, in turn, made it impossible to figure out whether the tests were failing due a bug in my code vs. failing due to resource constraints vs. some other reason. Once the timeout period was extended, it was possible to see that a) there was an actual bug in the code and b) trace the exception. The timeout issue is fixed in PR #375, which has now been merged to main

PS - Sorry for the confusion, and I hope my answer clarifies the issue

Ah I see, ok I think I get it, you're talking about local runs right? maybe it just worked smoothly on my mac but on a different machine it could be not as reliable 🤔

Anyways thanks a bunch for the explanation 🙂

@DataDrivenMD
Copy link
Contributor Author

Turns out there were 2 issues causing e2e tests to fail (now fixed):

  1. I needed to pass the DOMAIN=cloudflare.com binding to the e2e test suite in order to pull the instances stats. I added that binding to the yarn ci-dev-test-ui script in the package.json file.

  2. I needed to update the type definition used by the frontend to match the output from the Mastodon-compatible API

Separately, the TypeError that I shared above is still there but all tests are passing, so I don't know what to make of it. It seems to stem from the query builder code.

cc @dario-piotrowicz @xtuc

@DataDrivenMD
Copy link
Contributor Author

Just upstreamed all the changes in this branch. Should be ready again for you @xtuc

const headers = {
...cors(),
'content-type': 'application/json; charset=utf-8',
}

const res: any = {}
if (env.ADMIN_EMAIL === '[email protected]') {
db = await getDatabase(env)
Copy link
Member

Choose a reason for hiding this comment

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

why do you need this? db is already passed in the function, do you still need to call getDatabase?

// should go through the login flow and authenticate with Access.
// The documentation is incorrect and registrations is a boolean.
res.registrations = false
const statsDomain: string = env.ADMIN_EMAIL === '[email protected]' ? '0.0.0.0' : domain
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to avoid test specific behaviors in prod endpoints

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

Successfully merging this pull request may close these issues.

3 participants