1- import { Socket } from 'node:net' ;
2-
31import type { IParseAppPackageResult } from '@rocket.chat/apps/dist/server/compiler/IParseAppPackageResult' ;
42
53import { AppObjectRegistry } from '../../AppObjectRegistry' ;
@@ -11,19 +9,6 @@ import { RequestContext } from '../../lib/requestContext';
119const ALLOWED_NATIVE_MODULES = [ 'path' , 'url' , 'crypto' , 'buffer' , 'stream' , 'net' , 'http' , 'https' , 'zlib' , 'util' , 'punycode' , 'os' , 'querystring' , 'fs' ] ;
1210const ALLOWED_EXTERNAL_MODULES = [ 'uuid' ] ;
1311
14- function prepareEnvironment ( ) {
15- // Deno does not behave equally to Node when it comes to piping content to a socket
16- // So we intervene here
17- const originalFinal = Socket . prototype . _final ;
18- // deno-lint-ignore no-explicit-any
19- Socket . prototype . _final = function _final ( cb : any ) {
20- // Deno closes the readable stream in the Socket earlier than Node
21- // The exact reason for that is yet unknown, so we'll need to simply delay the execution
22- // which allows data to be read in a response
23- setTimeout ( ( ) => originalFinal . call ( this , cb ) , 1 ) ;
24- } ;
25- }
26-
2712// As the apps are bundled, the only times they will call require are
2813// 1. To require native modules
2914// 2. To require external npm packages we may provide
@@ -87,8 +72,6 @@ export default async function handleConstructApp(request: RequestContext): Promi
8772 throw new Error ( 'Invalid params' , { cause : 'invalid_param_type' } ) ;
8873 }
8974
90- prepareEnvironment ( ) ;
91-
9275 AppObjectRegistry . set ( 'id' , appPackage . info . id ) ;
9376 const source = sanitizeDeprecatedUsage ( appPackage . files [ appPackage . info . classFile ] ) ;
9477
0 commit comments