Files
upstream-mirror 30810eecd7
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

55 lines
2.3 KiB
TypeScript

import { Buffer } from 'node:buffer';
import { Socket } from 'node:net';
import process from 'node:process';
// Deno consumes the base as TypeScript source through the import map: ESM
// imports honor the map (`@rocket.chat/apps/` → `../`), so bare specifiers and
// `@rocket.chat/apps/*` resolve to allowed paths. Importing the compiled `dist`
// instead would run the base as CommonJS, whose `require()` bypasses the import
// map and falls back to node_modules — outside the subprocess read allowlist.
import { setSandboxGlobals, setSandboxRequire } from '@rocket.chat/apps/base-runtime/handlers/app/construct';
import { setTransport } from '@rocket.chat/apps/base-runtime/lib/messenger';
import { startMainLoop } from '@rocket.chat/apps/base-runtime/mainLoop';
import registerErrorListeners from './error-handlers';
import { require } from './lib/require';
import { stdoutTransport } from './lib/transports/stdoutTransport';
if (!process.argv.includes('--subprocess')) {
console.error(`
This is the Deno wrapper for the Rocket.Chat Apps runtime. It is not meant to be executed stand-alone;
It is instead meant to be executed as a subprocess by the Apps-Engine framework.
`);
process.exit(1);
}
function prepareEnvironment() {
// Deno does not behave equally to Node when it comes to piping content to a socket
// So we intervene here
const originalFinal = Socket.prototype._final;
// deno-lint-ignore no-explicit-any
Socket.prototype._final = function _final(cb: any) {
// Deno closes the readable stream in the Socket earlier than Node
// The exact reason for that is yet unknown, so we'll need to simply delay the execution
// which allows data to be read in a response
setTimeout(() => originalFinal.call(this, cb), 1);
};
}
// This runtime communicates with the Apps-Engine host through stdout
setTransport(stdoutTransport);
// Deno's sandbox `require` is a createRequire shim that resolves compiled
// apps-engine paths; the eval shell additionally needs a `Buffer` and a
// shadowed `Deno` (→ undefined) bound by name.
setSandboxRequire(require);
setSandboxGlobals({ Buffer, Deno: undefined });
// Process-global side effect; doing it once at startup is cleaner than inside construct
prepareEnvironment();
registerErrorListeners();
startMainLoop();