bluesky-social / bsky-docs

Bluesky API documentation
https://docs.bsky.app
Other
142 stars 115 forks source link

Docusaurus Build/Deploy Broken #246

Open bnewbold opened 4 days ago

bnewbold commented 4 days ago

Building this site on main branch is very slow and not working at all in our deploy environment (render.com).

There are at least two problems, both related to the auto-generated API reference docs:

  1. some of the auto-generated MDX files have gotten very large (eg, over 5MB), which makes the build step very slow and frequently hits out of memory (OOM)
  2. there is a build error with a specific API endpoint (tools.ozone.setting.removeOptions)
  3. build process sometimes fails with:
[ERROR] Client bundle compiled with errors therefore further build is impossible.
Unexpected end of JSON input

I have a branch https://github.com/bluesky-social/bsky-docs/pull/236 which fixes the second issue (simple patch), and desperately tries to work around the first issue by removing many of the MDX files (just rips API docs out of the site). This results in a working and faster build locally, but still fails to deploy due to the third issue, which I can't reproduce locally.

I suspect that the first issue might be caused by recursive/nested Lexicon references getting pulled in to generated docs, and an acceptable fix/mitigation might be to truncate the depth of nesting.

The second is probably fixed by just cherry-picking my commit.

The third I have no idea. Might need to create a temporary render.com account to trigger/debug.

As some high-level context, we have a plan to move generated API reference docs out of this repo and website and in to a generic Lexicon documentation site/service for all Lexicions in the ecosystem. So don't want to invest too much time in to that aspect. But will probably continue to use docusaurus for the dev blog, tutorials, and other docs.

Clarifications

I merged https://github.com/bluesky-social/bsky-docs/pull/247 which hopefully fixed problem two.

This repo / build process has multiple stages:

bnewbold commented 4 days ago

I just merged https://github.com/bluesky-social/bsky-docs/pull/247, which hopefully resolves problem two

sugyan commented 3 days ago

I attempted to reproduce and investigate the problem in an attempt to resolve this. As it turns out, the large mdx file seemed to be correct and the build failure was not reproduced.

Perhaps thanks to the fix in #247, the build succeeded fine in the local environment and on render.com. However, it is slow! It takes about 10 minutes.

I looked into the mdx files generated. Indeed, 5 of them, including app.bsky.feed.getFeed, are huge, over 5MB. However, I checked the contents and there are no recursive references, only because feedViewPost is deeply nested and large. To be more specific, the postView is quite large, and the feedViewPost is 3 times larger because it references the postView in .post, .reply.root, and .reply.parent, respectively.

I was concerned that docusaurus was slightly out of date. There seem to have been some performance improvements up to the latest 3.6, so I updated it to the latest version and related docusaurus-plugin-openapi-docs and so on. https://github.com/sugyan/bsky-docs/commit/3a9380c44cfab53c8fd53700755cc496ad0cce3c The mdx files are now smaller due to the new data generation format, but the build process still seems to take as long as the current one, or even longer. The results can be viewed without any problem. https://bsky-docs-246.onrender.com/docs/category/http-reference

I have tried several times to build & deploy using render.com so far and never reproduced the build failures you described in the third one.

In the end, it seems that the current bsky lexicon inevitably slows down the build because of the large postView. On the other hand, if you just want to speed up the build, replacing this would be very effective (although it would lose some detail in the documentation)

--- a/atproto-openapi-types/main.ts
+++ b/atproto-openapi-types/main.ts
@@ -70,6 +70,10 @@ for await (const entry of entries) {
         components.schemas![identifier] = convertArray(id, name, def);
         break;
       case "object":
+        if (id == "app.bsky.feed.defs" && name == "postView") {
+          components.schemas![identifier] = {};
+          break;
+        }
         components.schemas![identifier] = convertObject(id, name, def);
         break;
       case "procedure": {