Skip to content

fix(apps): write ephemeral Deno config to writable runtime directory#41322

Open
iamtanishqjain wants to merge 2 commits into
RocketChat:developfrom
iamtanishqjain:fix/41015-deno-runtime-config
Open

fix(apps): write ephemeral Deno config to writable runtime directory#41322
iamtanishqjain wants to merge 2 commits into
RocketChat:developfrom
iamtanishqjain:fix/41015-deno-runtime-config

Conversation

@iamtanishqjain

@iamtanishqjain iamtanishqjain commented Jul 11, 2026

Copy link
Copy Markdown

Summary

This PR proposes Related to #41015.

Currently, the runtime generates deno.runtime.jsonc alongside the bundled deno.jsonc. On Snap deployments, the package directory is mounted read-only, causing EROFS when the runtime attempts to create the generated configuration.

This change updates the generated runtime configuration path to use the existing temporary deno-runtime directory instead of deriving it from the bundled configuration path.

Motivation

The runtime already executes from a temporary deno-runtime directory. Generating the ephemeral configuration in the same writable runtime location avoids writes to the immutable Snap package directory.

Fixes #41015

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved runtime configuration handling by storing temporary Deno configuration files in a dedicated runtime directory.
    • Helps ensure Deno applications start reliably when using generated configuration files.

@iamtanishqjain iamtanishqjain requested a review from a team as a code owner July 11, 2026 07:09
@dionisio-bot

dionisio-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3c06fdf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Deno runtime now places its generated ephemeral configuration at a deterministic path inside the temporary runtime directory rather than deriving the path from the packaged Deno configuration file.

Changes

Deno runtime configuration

Layer / File(s) Summary
Relocate ephemeral configuration path
packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
denoEphemeralConfigPath now uses <tempFilePath>/deno-runtime/deno.runtime.jsonc via path.join.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely matches the main change: moving the ephemeral Deno config to a writable runtime directory.
Linked Issues check ✅ Passed The change writes deno.runtime.jsonc to the temp deno-runtime directory, matching issue #41015's requirement for a writable temp path.
Out of Scope Changes check ✅ Passed The only change shown is the runtime config path relocation, which is directly tied to the Snap read-only filesystem fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts`:
- Around line 70-74: The ephemeral config path in AppsEngineDenoRuntime still
traverses the deno-runtime symlink into the read-only package directory. Update
denoEphemeralConfigPath to a writable location outside the symlinked
deno-runtime directory, and ensure its parent directory exists before the write
performed by the runtime configuration setup near the symlink creation logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b152b0e-8b0a-45e8-8410-5ca7547ff3ea

📥 Commits

Reviewing files that changed from the base of the PR and between 719e3db and b6a8213.

📒 Files selected for processing (1)
  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: CodeRabbit
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
🧠 Learnings (4)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
📚 Learning: 2026-05-11T21:46:23.471Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 40463
File: packages/apps/src/lib/SecureFields.ts:17-19
Timestamp: 2026-05-11T21:46:23.471Z
Learning: In Rocket.Chat’s `packages/apps/tsconfig.json`, TypeScript `"strict"` is set to `false`, which disables strict type-checking (including `noImplicitAny`) for `packages/apps`. When reviewing, do not flag TS7053 (and similar strict-mode indexing/type errors) in files under `packages/apps/src/` that are a consequence of this relaxed strictness—e.g., patterns like indexing an `unknown`/`object` via optional chaining such as `object?.[kSecureFields]`.

Applied to files:

  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts

Comment on lines +70 to +74
this.denoEphemeralConfigPath = path.join(
this.tempFilePath,
'deno-runtime',
'deno.runtime.jsonc',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win

The ephemeral config still resolves to the read-only package directory through the symlink.

Line 82 creates a symlink: this.tempFilePath/deno-runtime/path.dirname(this.denoConfigPath) (the package's Deno config directory, which is read-only on Snap). The new denoEphemeralConfigPath at lines 70-74 is this.tempFilePath/deno-runtime/deno.runtime.jsonc, which resolves through that symlink to path.dirname(this.denoConfigPath)/deno.runtime.jsonc — the same read-only location the old code wrote to. The fs.writeFileSync at line 45 (invoked via line 90) will still fail with EROFS on Snap deployments, so this PR does not achieve its stated objective.

The fix is to place the ephemeral config in a directory that is not covered by the symlink:

🐛 Proposed fix: write ephemeral config outside the symlinked directory
	this.denoRuntimePath = path.join(this.tempFilePath, 'deno-runtime', 'main.ts');
-	this.denoEphemeralConfigPath = path.join(
-		this.tempFilePath,
-		'deno-runtime',
-		'deno.runtime.jsonc',
-	);
+	this.denoEphemeralConfigPath = path.join(this.tempFilePath, 'deno-runtime-config', 'deno.runtime.jsonc');

Then ensure the parent directory exists before writing (add before line 90):

+	fs.mkdirSync(path.dirname(this.denoEphemeralConfigPath), { recursive: true });
 	generateEphemeralDenoConfig(this.denoEphemeralConfigPath, this.denoConfigPath, this.appsEnginePath);

This keeps the ephemeral config in the writable temp directory while the symlink at deno-runtime/ continues to expose only the runtime script (main.ts) and other static files from the package.

Also applies to: 82-90

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts` around lines
70 - 74, The ephemeral config path in AppsEngineDenoRuntime still traverses the
deno-runtime symlink into the read-only package directory. Update
denoEphemeralConfigPath to a writable location outside the symlinked
deno-runtime directory, and ensure its parent directory exists before the write
performed by the runtime configuration setup near the symlink creation logic.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts">

<violation number="1" location="packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts:70">
P0: Writing ephemeral config to `<tempFilePath>/deno-runtime/deno.runtime.jsonc` goes through the symlink back to the read-only package directory, so the EROFS error on Snap deployments persists — the fix doesn't reach writable storage. The constructor creates a 'dir' symlink at `<tempFilePath>/deno-runtime` → `<packageDir>/deno-runtime/` before the config write. Write the ephemeral config to a path that does not traverse the symlink, e.g. `path.join(this.tempFilePath, 'deno.runtime.jsonc')`, and update `generateEphemeralDenoConfig` and the `--config` arg accordingly.</violation>

<violation number="2" location="packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts:70">
P3: Indentation is inconsistent with the rest of the constructor body. The surrounding code uses two tabs for statements inside the constructor, but the new lines use only one tab. Consider aligning the indentation to match the file's convention (two tabs for constructor-body statements).</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


this.denoRuntimePath = path.join(this.tempFilePath, 'deno-runtime', 'main.ts');
this.denoEphemeralConfigPath = this.denoConfigPath.replace('.jsonc', '.runtime.jsonc');
this.denoEphemeralConfigPath = path.join(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: Writing ephemeral config to <tempFilePath>/deno-runtime/deno.runtime.jsonc goes through the symlink back to the read-only package directory, so the EROFS error on Snap deployments persists — the fix doesn't reach writable storage. The constructor creates a 'dir' symlink at <tempFilePath>/deno-runtime<packageDir>/deno-runtime/ before the config write. Write the ephemeral config to a path that does not traverse the symlink, e.g. path.join(this.tempFilePath, 'deno.runtime.jsonc'), and update generateEphemeralDenoConfig and the --config arg accordingly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts, line 70:

<comment>Writing ephemeral config to `<tempFilePath>/deno-runtime/deno.runtime.jsonc` goes through the symlink back to the read-only package directory, so the EROFS error on Snap deployments persists — the fix doesn't reach writable storage. The constructor creates a 'dir' symlink at `<tempFilePath>/deno-runtime` → `<packageDir>/deno-runtime/` before the config write. Write the ephemeral config to a path that does not traverse the symlink, e.g. `path.join(this.tempFilePath, 'deno.runtime.jsonc')`, and update `generateEphemeralDenoConfig` and the `--config` arg accordingly.</comment>

<file context>
@@ -67,7 +67,12 @@ export class DenoRuntimeSubprocessController extends BaseRuntimeSubprocessContro
 
 		this.denoRuntimePath = path.join(this.tempFilePath, 'deno-runtime', 'main.ts');
-		this.denoEphemeralConfigPath = this.denoConfigPath.replace('.jsonc', '.runtime.jsonc');
+	this.denoEphemeralConfigPath = path.join(
+	this.tempFilePath,
+	'deno-runtime',
</file context>

Comment on lines +70 to +73
this.denoEphemeralConfigPath = path.join(
this.tempFilePath,
'deno-runtime',
'deno.runtime.jsonc',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Indentation is inconsistent with the rest of the constructor body. The surrounding code uses two tabs for statements inside the constructor, but the new lines use only one tab. Consider aligning the indentation to match the file's convention (two tabs for constructor-body statements).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts, line 70:

<comment>Indentation is inconsistent with the rest of the constructor body. The surrounding code uses two tabs for statements inside the constructor, but the new lines use only one tab. Consider aligning the indentation to match the file's convention (two tabs for constructor-body statements).</comment>

<file context>
@@ -67,7 +67,12 @@ export class DenoRuntimeSubprocessController extends BaseRuntimeSubprocessContro
 
 		this.denoRuntimePath = path.join(this.tempFilePath, 'deno-runtime', 'main.ts');
-		this.denoEphemeralConfigPath = this.denoConfigPath.replace('.jsonc', '.runtime.jsonc');
+	this.denoEphemeralConfigPath = path.join(
+	this.tempFilePath,
+	'deno-runtime',
</file context>
Suggested change
this.denoEphemeralConfigPath = path.join(
this.tempFilePath,
'deno-runtime',
'deno.runtime.jsonc',
this.denoEphemeralConfigPath = path.join(
this.tempFilePath,
'deno-runtime',
'deno.runtime.jsonc',
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App compilation fails on snap install due to read-only Deno temp location

2 participants