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

Failed to register new resource (sourcemaps), no such file or directory #72

Closed
frankieramirez opened this issue Mar 26, 2024 · 2 comments
Assignees

Comments

@frankieramirez
Copy link

frankieramirez commented Mar 26, 2024

I'm getting this error when attempting to deploy a Next.js application:

Error: failed to register new resource SiteSourcemap5edb9939 [aws:s3/bucketObjectv2:BucketObjectv2]: 2 UNKNOWN: failed to compute asset hash for "source": failed to open asset file '.next/server/app/my-page/page.js.map': open .next/server/app/my-page/page.js.map: no such file or directory
at new Resource (/home/runner/work/my-app/my-app/.sst/platform/node_modules/@pulumi/aws/node_modules/@pulumi/resource.ts:507:13)
    at new CustomResource (/home/runner/work/my-app/my-app/.sst/platform/node_modules/@pulumi/aws/node_modules/@pulumi/resource.ts:897:9)
    at new BucketObjectv2 (/home/runner/work/my-app/my-app/.sst/platform/node_modules/@pulumi/s3/bucketObjectv2.ts:439:9)
    at file:///home/runner/work/my-app/my-app/.sst/platform/src/components/aws/nextjs.ts:1388:13
    at Array.forEach (<anonymous>)
    at file:///home/runner/work/my-app/my-app/.sst/platform/src/components/aws/nextjs.ts:1385:18
    at /home/runner/work/my-app/my-app/.sst/platform/node_modules/@pulumi/output.ts:398:31
    at Generator.next (<anonymous>)
    at /home/runner/work/my-app/my-app/.sst/platform/node_modules/@pulumi/pulumi/output.js:21:71

I traced the issue to .sst/platform/src/components/aws/nextjs.ts and its uploadSourcemaps function. I was able to patch locally by updating the source path for new aws.s3.BucketObjectv2:

function uploadSourcemaps() {
      logging.apply((logging) => {
        if (logging !== "per-route") return;

        useRoutes().apply((routes) => {
          routes.forEach(({ sourcemapPath, sourcemapKey }) => {
            if (!sourcemapPath || !sourcemapKey) return;
            outputPath.apply((outputPath) => {
              new aws.s3.BucketObjectv2(
                `${name}Sourcemap${sanitizeToPascalCase(sourcemapKey)}`,
                {
                  bucket: region.apply((region) =>
                    bootstrap.forRegion(region).then((b) => b.asset),
                  ),
                  source: new asset.FileAsset(
                    path.resolve(outputPath, sourcemapPath),
                  ),
                  key: serverFunction!.nodes.function.arn.apply((arn) =>
                    path.posix.join("sourcemaps", arn, sourcemapKey),
                  ),
                },
                { parent, retainOnDelete: true },
              );
            });
          });
        });
      });
    }

This doesn't help when attempting to deploy via CI so it'd be great if someone could look into this.

ION-220

@jayair
Copy link
Contributor

jayair commented Mar 26, 2024

@fwang take a look?

@thdxr thdxr added the linear Created by Linear-GitHub Sync label Mar 28, 2024
@thdxr thdxr changed the title Failed to register new resource (sourcemaps), no such file or directory [ION-220] Failed to register new resource (sourcemaps), no such file or directory Mar 28, 2024
@thdxr thdxr added linear Created by Linear-GitHub Sync and removed linear Created by Linear-GitHub Sync labels Mar 28, 2024
@thdxr thdxr changed the title [ION-220] Failed to register new resource (sourcemaps), no such file or directory Failed to register new resource (sourcemaps), no such file or directory Mar 28, 2024
@fwang
Copy link
Contributor

fwang commented Mar 28, 2024

@frankieramirez should be fixed in v0.0.220.

Feel free to reopen if issue persisnt.

@fwang fwang closed this as completed Mar 28, 2024
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

No branches or pull requests

4 participants