Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not functional under docker container. #16

Open
seanjiang86 opened this issue Nov 20, 2018 · 9 comments
Open

Not functional under docker container. #16

seanjiang86 opened this issue Nov 20, 2018 · 9 comments
Labels

Comments

@seanjiang86
Copy link

Basically two issues:
When I use something like:

const configF = await hotImport('config.js')
const config = configF()

like the sample, I am getting an error says configF is not a function.

When I try something like:

 const configF = await hotImport('config.js')
 const config = configF.config;

while the "config.js" has the content like this:

export const config = {
  ......
}

I am able to get the config content. However, when I use this piece of code in an event listener, something is not working. For the first time it executed, every thing works fine, but on the second run of the event, the “configF" becomes underfined and I am getting an error on "configF.config".
I am wondering has anyone else experienced such issue and could give me an explain?

@huan
Copy link
Owner

huan commented Nov 20, 2018

Can you provide a reproduce-able code with the description in detail so that we can have a look into it?

@seanjiang86
Copy link
Author

Such a quick response:) Actually I am trying your wechaty bot and using your https://github.com/Chatie/wechaty-getting-started
The sample I use is in "examples/professional/monster-bot/"
The environment I use is your suggested docker image :
zixia/wechaty on docker version 18.06.1-ce on win10.
I hope this message should be able to suggest my image version:
Starting Docker Container for Wechaty v0.23.19 with Node.js v10.13.0 ...
There are few other minor issues with the default script in my environment like the "Misc" is underfined that I am still checking. The hot-import issue appears the most weird one for me by now.
Anyway, thanks for the wechaty framework you provide. It is a very powerfully tool and hope to work on details of it when I am skilled enough :)

@huan
Copy link
Owner

huan commented Nov 20, 2018

Thanks for providing that information.

If you want to make sure the hot-import part is workable, could you try the other example at https://github.com/Chatie/wechaty-getting-started/tree/master/examples/professional/hot-import-bot because that's written by me and it should work without any problem?

The monster-bot is from other contributors: @suntong , so I can not guarantee it compatible with hot-import.

@seanjiang86
Copy link
Author

I got a little confused. I have tried to change some log content in the listeners\on-message.js while the bot is running, but the log content remains the same after the change.
When I check with the codes in hot-import-bot, there is no place to explicitly import the ”hot-import". If the "wechaty" is implicitly binding listeners through hot-import, I am worrying the "wecahty" in the published image might not containing this feature.

@huan
Copy link
Owner

huan commented Nov 20, 2018

The latest version of published docker image and npm module had all included this feature as well.

https://github.com/Chatie/wechaty-getting-started/blob/ba723342d972f313a8ba6f2e07bbfc0883805075/examples/professional/hot-import-bot/hot-import-bot.js#L37-L42

Please pay attention on the above lines, like .on('message', './listeners/on-message'), the event listener here, is a string instead a function.

Inside Wechaty, if we found you passed a string to a event listener, we will treat it as a import-able js module, and use hot-import to load it.

@huan huan added the question label Nov 20, 2018
@seanjiang86
Copy link
Author

I understand your explain and point. The issue is I am not able to see the hot-import working at my environment. After switching the content inside the onMessage file, nothing changed for the robot. I have even tried delete the on-message file and everything still works fine. Both the cnpm(taobao) image and npm image is not working. I will try check whether some default caching mechanism has been enabled for the docker container on win10. Thanks for your explain.

@huan
Copy link
Owner

huan commented Nov 20, 2018

Can you try it without docker?

It might be related to the docker container because we have limited privileges inside the docker.

I had run this example under native Linux without any problem before.

P.S. after the handler file is loaded, the node system can work without any problem even you delete the handler file, this is the right behavior.

@seanjiang86
Copy link
Author

Ha, it is fully functional without docker. It is working fine in windows node envirnoment. Will close this issue and try reproducing hot-import issue in event listener seperately. It's up to you to check the container issue, I will also try on a different OS. Thanks for your time!

@huan
Copy link
Owner

huan commented Nov 20, 2018

Glad to hear that, and I think we should keep this issue open as a bug with container technology.

@huan huan reopened this Nov 20, 2018
@huan huan changed the title Issue using hot-import Not functional under docket container. Nov 20, 2018
@seanjiang86 seanjiang86 changed the title Not functional under docket container. Not functional under docker container. Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants