stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.89k stars 160 forks source link

isomorphic-git can't push in webcontainer #654

Closed FossPrime closed 2 years ago

FossPrime commented 2 years ago

Describe the bug

The following shell command run fine in Node 16/14 on an Ubuntu machine, but fail on WebContainers

/tmp/test-dir
> npx isomorphic-git push --corsProxy='https://cors-proxy.myproxy.app' --url='https://JohnDoe:glpat-123@gitlab.com/my-repo.git'
success Install finished in 2.27s

One or more branches were not updated: 
  - refs/heads/main: unpacker error
GitPushError: One or more branches were not updated: 
  - refs/heads/main: unpacker error
    at _push (/home/.turbo/npx/LOzMwT/node_modules/isomorphic-git/index.cjs:11731:11)
    at async Object.push (/home/.turbo/npx/LOzMwT/node_modules/isomorphic-git/index.cjs:11809:12)
    at async eval (/home/.turbo/npx/LOzMwT/node_modules/isomorphic-git/cli.cjs:14:20) {
  caller: 'git.push',
  code: 'GitPushError',
  data: {
    prettyDetails: '\n  - refs/heads/main: unpacker error',
    result: {
      ok: false,
      error: 'unpack-objects abnormal exit',
      refs: { 'refs/heads/main': { ok: false, error: 'unpacker error' } },
      headers: {
          'cache-control': 'no-cache',
          'content-type': 'application/x-git-receive-pack-result',
          date: 'Mon, 28 Mar 2022 16:14:39 GMT',
          server: 'nginx/1.21.0',
          'transfer-encoding': 'chunked'
      }
    }
  }
}

Everything else seems to work fine. The same error occurs when running from a script instead of the CLI.

The issue seems to be some incompatibility with WebContainer FS, HTTP, or jsh.

Link to the blitz that caused the error

https://stackblitz.com/edit/node-b7uvun

Steps to reproduce

  1. make a commit
  2. Attempt to push the commit with npx isomorphic-git push --corsProxy='https://cors.isomorphic-git.org' --url='https://JohnDoe:glpat-123@gitlab.com/my-repo.git

Expected behavior

This is the result of a successful push using the exact same commands in Node 14 and Node 16 Ubuntu.

npx: installed 24 in 2.736s
{
  "ok": true,
  "refs": {
    "refs/heads/main": {
      "ok": true,
      "error": ""
    }
  },
  "headers": {
    "server": "nginx/1.21.0",
    "date": "Mon, 28 Mar 2022 16:27:45 GMT",
    "content-type": "application/x-git-receive-pack-result",
    "transfer-encoding": "chunked",
    "connection": "close",
    "access-control-allow-origin": "*",
    "access-control-expose-headers": "accept-ranges,age,cache-control,content-length,content-language,content-type,date,etag,expires,last-modified,location,pragma,server,transfer-encoding,vary,x-github-request-id,x-redirected-url",
    "cache-control": "no-cache"
  }
}

Parity with Local

Screenshots

No response

Platform

Node: WebContainer Node 14 isomorphic-git: 1.17.0 Chrome: 99

Additional context

Related: https://github.com/isomorphic-git/isomorphic-git/issues/1523

SamVerschueren commented 2 years ago

Hey @rayfoss, thanks for reporting this issue.

After digging into it a bit deeper, I found out that we don't handle binary payloads correctly. I will fix this and get back to you when it's released. Can't give an estimate when it will be released, but should be one of the following days.

FossPrime commented 2 years ago

Has the fix been released? As of Hash = 31afbfcfe1b0985e8cbdb27d44e16766166a118e I'm still getting a webcontainer unique error.

https://stackblitz.com/edit/node-jdru2t?file=index.mjs

{
  ok: false,
  error: 'index-pack abnormal exit',
  refs: { 'refs/heads/master': { ok: false, error: 'failed' } },
  headers: {
    'cache-control': 'no-cache, max-age=0, must-revalidate',
    'content-type': 'application/x-git-receive-pack-result',
    date: 'Tue, 05 Apr 2022 16:21:40 GMT',
    expires: 'Fri, 01 Jan 1980 00:00:00 GMT',
    pragma: 'no-cache',
    server: 'nginx/1.21.0',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding',
    'x-github-request-id': 'E2C2:8041:12F2DA:22CBA2:624C6C94'
  }
d3lm commented 2 years ago

Hey there 👋

No the fix is not deployed yet. We'll let you know once it's on production.

SamVerschueren commented 2 years ago

This issue should be fixed now! Thanks for your patience 🙏 .