RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.

Home Page:https://rocketchat.github.io/Rocket.Chat.Apps-engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App deployment to server

smcardle opened this issue · comments

Hi.

I created an App Engine app called "First Message" on my MBP (OSX) to deploy to our RC Docker instance running on Ubuntu 16.04

RC version 1.2.1 - From Docker Hub
Apps Engine version 1.4.2

Then run locally on my MBP
rc-apps deploy

Results in the following errors:

Steves-MacBook-Pro:first-message stevenmcardle$ rc-apps deploy -f --url=https://app.<domain>.<tld> --username=<admin-username>
packaging your app... packaged!
And, what is the password?: *************
deploying your app... !
Error: Deployment error: Debug Failure. False expression.
    at Deploy.asyncSubmitData (/usr/local/lib/node_modules/@rocket.chat/apps-cli/lib/commands/deploy.js:100:19)
Steves-MacBook-Pro:first-message stevenmcardle$ 

Is this a known issue ???

If not, does anybody know why the call to /api/apps fails like this ???

UPDATE: *******

The log file for the Rocket.Chat docker instance reports the following:

app_app.1.b9vi7mn1e5s0@manager03    | Failed to resolve module: vm
app_app.1.b9vi7mn1e5s0@manager03    | Failed to resolved 1 modules for First Message v0.0.1!

I have the same problem. I am using apps-engine@1.7.0. But updating to apps-engine@1.11.0 doesn't fix it.
But it cannot find 'stream' and 'net' modules.

packaging your app... finished!
App packaged up at: /home/.../chat-app/dist/app_0.0.5.zip

This line appears in logs before errors:

I20200319-13:47:00.765(5)? /home/.../Rocket.Chat/node_modules/@types/node/child_process.d.ts [ 'events', 'stream', 'net' ]

I suppose it is due to:

Error: /home/.../chat-app/node_modules/@rocket.chat/apps-engine/definition/accessors/IUploadRead.d.ts
› (4,40):
› Cannot find name 'Buffer'. Do you need to install type definitions for node? Try npm i @types/node.

@NNesh @smcardle
I am facing a similar error. Did u found a solution? If yes, then, please share!!
Thanks in advance.

Hi @murtaza98 ! Could you please share a minimal app here that can reproduce the issue. Thank you!

Hi @lolimay
Heres a simple app in which I've added the new imports. (See here)

This is the SS of RC server logs before this edit. As u can see that the app wasn't getting deployed and was complaining about unresolved module
Screenshot from 2020-03-27 12-23-13
Screenshot from 2020-03-27 12-23-28

After this new commit, where I've added support for all built-in modules, the app is successfully getting deployed.
Screenshot from 2020-03-27 12-34-18
Screenshot from 2020-03-27 12-34-32

Hope this helps, have a great day :)

Ah, I got your point. @murtaza98 ! since the Rocket.Chat apps are not full-featured Node.js apps that we can only provide a subset of node builtin modules. For vm or some other Node.js builtin modules, we wouldn't make them accessible now, neither in the future.

Please use our APIs as much as possible, if there're missing features that we didn't provide yet. Feel free to fire a new issue in our repo!

Hi, @lolimay! A minimal app is here. I have not added any node modules, but I see the same errors, excepting 'vm'.

Hi, @lolimay! A minimal app is here. I have not added any node modules, but I see the same errors, excepting 'vm'.

Hey @NNesh ! Thanks for the app shared. I cloned it and deployed it to the server sucessfully.
image

Can you please tell me your apps-engine version, RocketChat version and apps-cli (rc-apps) version?

@lolimay Rocket.Chat has version 2.3.2, Apps-Engine - 1.11.0 (downgrading to 1.7.0 doesn't fix it) and apps-cli - 1.6.0.

It has tried to resolve modules in @types/node/child_process.d.ts:

declare module "child_process" {
    import * as events from "events";
    import * as stream from "stream";
    import * as net from "net";

    ...

I think it happens because https://github.com/RocketChat/Rocket.Chat.Apps-engine/blob/master/src/definition/accessors/IUploadRead.ts is using Buffer. But I am not sure...

Ah, I got your point. @murtaza98 ! since the Rocket.Chat apps are not full-featured Node.js apps that we can only provide a subset of node builtin modules. For vm or some other Node.js builtin modules, we wouldn't make them accessible now, neither in the future.

Please use our APIs as much as possible, if there're missing features that we didn't provide yet. Feel free to fire a new issue in our repo!

@lolimay I understand ur point. U mentioned that u cannot include modules like vm as it will be is a security risk.

However currently the app engine only support 4 built in modules as u can see in this file.
So what I am thinking, we can add some support for some more built in node modules which are safe. We won't include node modules like vm, process, child_process which are a not safe from security stand point. However we can include modules like assert, stream, timers, etc, which are harmless.

What do u think abt this?
I u agree, then I will create a list of all safe modules n submit a pull request.

Thanks n have a great day.