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

Publish failed due to "Could not find MODULE.bazel", not sure how to debug #176

Closed
jmillikin opened this issue Nov 16, 2024 · 7 comments · Fixed by #178
Closed

Publish failed due to "Could not find MODULE.bazel", not sure how to debug #176

jmillikin opened this issue Nov 16, 2024 · 7 comments · Fixed by #178

Comments

@jmillikin
Copy link
Contributor

I just cut rules_m4 v0.2.4 (https://github.com/jmillikin/rules_m4/releases/tag/v0.2.4), but publish-to-bcr failed:

Failed to publish entry for jmillikin/rules_m4@v0.2.4 to the Bazel Central Registry.

Could not find MODULE.bazel in release archive at ./MODULE.bazel.
Is the strip prefix in source.template.json correct? (currently it's '')

The source archive does contain a MODULE.bazel file at the top level:

$ tar -tf rules_m4-v0.2.4.tar.xz | grep MODULE
MODULE.bazel

I suspect the underlying cause is somewhere in the recently-added .tar.xz support (is it not extracting properly?), but the error email contains no logs or information so it's difficult to debug.

@jmillikin
Copy link
Contributor Author

Gentle ping @kormide -- do the logs show anything that might be related? I've not been able to figure out how to get this project to run locally for testing.

@kormide
Copy link
Collaborator

kormide commented Nov 24, 2024

Sorry for the delay. I'll fork your repo and try to reproduce it in the dev environment I have set up.

@kormide
Copy link
Collaborator

kormide commented Nov 24, 2024

How do you produce and upload the release archive?

Nevermind, I can just hardcode the source url to one of your existing release archives.

@kormide
Copy link
Collaborator

kormide commented Nov 24, 2024

I found the issue. We aren't waiting for the writable stream to close after decompressing. Fixing this revealed another bug. I'll get some fixes up soon.

@kormide
Copy link
Collaborator

kormide commented Nov 24, 2024

After fixing the waiting issue, it seems that the extracted contents are not correct. For example, it's trying to parse the extracted MODULE.bazel file, but that file contains contents from your m4_repository.bzl file.

@jmillikin
Copy link
Contributor Author

I was able to reproduce the incorrect MODULE.bazel content, but I'm confused about why it's happening. The output stream is observing chunks of bytes being written in the wrong order -- I can console.log to verify the decompressed bytes are correct, but the stream is seeing chunk 2 being written with the contents of chunk 3.

Is it possible that Node's file streams require explicit synchronization to preserve order between calls? This doesn't make sense to me, but the following diff seems to fix the problem (the logged bytes and streamed bytes become the same).

diff --git a/src/infrastructure/xzdec/xzdec.ts b/src/infrastructure/xzdec/xzdec.ts
index 208d150..5fd9efc 100644
--- a/src/infrastructure/xzdec/xzdec.ts
+++ b/src/infrastructure/xzdec/xzdec.ts
@@ -126,7 +126,11 @@ export async function decompress(r: stream.Readable, w: stream.Writable) {
           }
           const outputLen = peekU32(mem, outputLenPtr);
           if (outputLen > 0) {
-            w.write(Buffer.from(mem.buffer, outputPtr, outputLen));
+            await (new Promise((resolve) => {
+                w.write(Buffer.from(mem.buffer, outputPtr, outputLen), () => {
+                    resolve(null);
+                });
+            }));
           }
         }
       }

@kormide
Copy link
Collaborator

kormide commented Nov 26, 2024

The fixes have been deployed to prod.

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 a pull request may close this issue.

2 participants