temporalio / temporalio/sdk-typescript

extractSourceMap takes a huge amount of RAM on boot

Open
#1,772 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
917
Forks
224
Avg merge
3d 16h
Merged PRs (30d)
43

Description

I run a series of workers on my Temporal pod bootup. They sometimes take up over 2GB of RAM simply from parsing the source maps. I've confirmed this using clinic.js.

Image

https://github.com/temporalio/sdk-typescript/blob/5473ebd3442d00624fb0ed20fa82f8d5bd78e8fd/packages/worker/src/worker.ts#L1868

I am curious if there is a way to optionally allow turning off source maps? I can do so via the builder

	const { code } = await bundleWorkflowCode({
		workflowsPath: worker.workflowsPath,
		// Remove source maps
		webpackConfigHook: config => {
			config.devtool = false;
			return config;
		}
	});

But then the extractSourceMap throws, and if I patch it I see further failures down the line in addWorkflowBundle > SourceMapConsumer

I managed to patch it (in a dirty way)

    return [code, JSON.stringify({
            version: 3,
            file: '',
            sources: [],
            mappings: '',
    })];
    // throw new Error("Can't extract inlined source map from the provided Workflow Bundle");

Which results in significantly lower bootup + IDLE ram usage

Before

Image

After

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/worker/src/worker.ts around line 1868 and trace extractSourceMap through addWorkflowBundle and SourceMapConsumer. Compare the normal source-map path with the webpackConfigHook configuration that sets devtool to false, using the reported clinic.js memory behavior as context. Done means source maps can be disabled without the later failures and worker boot and idle memory are substantially reduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
build-system, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.