encore icon indicating copy to clipboard operation
encore copied to clipboard

Internal Compiler Error: runtime error: invalid memory address or nil pointer dereference (Encore clientgen)

Open sanjay-complyance opened this issue 9 months ago • 2 comments

I encountered an internal compiler error while running npx encore gen in my monorepo. The error message is:

An unhandled panic occurred in the Encore compiler: runtime error: invalid memory address or nil pointer dereference

This is a bug in Encore and should not have occurred. Please report this issue to the Encore team
either on Github at https://github.com/encoredev/encore/issues/new and include this error.

╭─[Stack Trace]
├─▶ clientgen.Client.func1                encr.dev/pkg/clientgen/client.go:65
├─▶ clientgen.(*typescript).handleBailout encr.dev/pkg/clientgen/typescript.go:1816
├─▶ clientgen.(*typescript).isRecursive   encr.dev/pkg/clientgen/typescript.go:1924
├─▶ clientgen.(*typescript).writeTyp      encr.dev/pkg/clientgen/typescript.go:1774
├─▶ clientgen.(*typescript).writeService  encr.dev/pkg/clientgen/typescript.go:427
├─▶ clientgen.(*typescript).Generate      encr.dev/pkg/clientgen/typescript.go:104
╰─[... remaining frames omitted ...]

What I was doing:

  • I have a monorepo with multiple Encore services.
  • I tried to regenerate the TypeScript client after exposing new endpoints in one of my services

Encore version:
1.46.22

Node version:
22.14.0

OS:
macOS 14.5 (darwin 24.5.0)

Anything else that might help:

  • I tried running npx encore clean and npx encore gen again, but the error persists.
  • If you need more details or a minimal reproduction, let me know!

sanjay-complyance avatar May 30 '25 20:05 sanjay-complyance

Can you please provide more details / reproducer of the change you made that caused this error?

marcuskohlberg avatar Jun 19 '25 12:06 marcuskohlberg

Hey! After doing some debugging, I was able to track down the API definition that’s causing the issue:

// Transfer workspace ownership
export const transferOwnership = api(
  {
    method: "POST",
    path: "/workspaces/:workspaceId/transfer-ownership",
    expose: true,
    auth: true,
  },
  async ({
    workspaceId,
    currentOwnerId,
    newOwnerId,
    isLeaving,
  }: {
    workspaceId: string;
    currentOwnerId: string;
    newOwnerId: string;
    isLeaving: boolean;
  }): Promise<{
    newOwner: IWorkspaceMembership;
    previousOwner: IWorkspaceMembership | null;
  }> => {
    await ensureDbConnected();

Let me know if you need anything else from my side!

sanjay-complyance avatar Jun 20 '25 07:06 sanjay-complyance