react-native-worklets-core icon indicating copy to clipboard operation
react-native-worklets-core copied to clipboard

Async/Await in Worklet Functions

Open robnewton opened this issue 2 years ago • 3 comments

Is it possible to use async/await within Worklets?

I'm trying to make calls to asynchronous functions outside of the function tagged with the worklet keyword? As a simple example, is it possible to use the Expo FileSystem async functions like copyFileAsync() from within a worklet?

When tried, I get errors like this:

TypeError: Cannot assign to read only property 'message' of object 'SyntaxError: unknown: Unexpected reserved word 'yield'.

robnewton avatar Aug 22 '23 04:08 robnewton

应该是这里错了 gulpSSH.dest('/dist'), 你没有该根目录的权限 /dist

zensh avatar Jun 06 '16 00:06 zensh

i have this same error seems plugin isn't working

ta3pks avatar Jun 09 '16 12:06 ta3pks

gulp.task("sendFile",["build"], _ => {
    return gulp.src("../stats_x86_64")
        .pipe(ssh.dest("/home/nikos/"));
})
gulp.task("deploy", ["sendFile"], _ => {
    return ssh.exec(["chmod a+x /home/nikos/stats_x86*","exit"]).pipe(gulp.dest("logs"))
})

here is my code

ta3pks avatar Jun 09 '16 12:06 ta3pks

gulp.src("../stats_x86_64/**/*")

zensh avatar Jun 10 '16 02:06 zensh

@zensh stats_x86_64 is an executable not a folder

ta3pks avatar Jun 10 '16 22:06 ta3pks

@NikosEfthias You should remove _ from => function

zensh avatar Jun 11 '16 03:06 zensh

it tells function will not have any parameters in es6 syntax what it has to do with ssh ?

ta3pks avatar Jun 11 '16 06:06 ta3pks

I get the same error too

[14:50:36] 'deploy' errored after 4.35 s
[14:50:36] Error in plugin 'gulp-ssh'
Message:
    Failure
Details:
    code: 4
    lang:

My code,

gulp.task("deploy", function() {
    if(webDeployConfig.enabled)
    {
        var gulpSSH = new GulpSSH({
            ignoreErrors: true,
            sshConfig: {
                host: webDeployConfig.webserver,
                port: webDeployConfig.port,
                username: webDeployConfig.username,
                password: webDeployConfig.password
            }
        });

        return gulp.src(['target/**/*.*', '!target/**/*.ts', '!target/**/*.map'])
            .pipe(gulpSSH.dest(webDeployConfig.uploadDirectoryPath));
    }
    else
    {
        console.log("deploy is disabled!");
    }
});

goldenratio avatar Jul 06 '16 11:07 goldenratio

events.js:141
      throw er; // Unhandled 'error' event
      ^
 Error: Failure
    at SFTPStream._transform (F:\gulp-ssh\node_modules\ssh2\node_modules\ssh2-streams\lib\sftp.js:384:27)
    at SFTPStream.Transform._read (_stream_transform.js:167:10)
    at SFTPStream._read (F:\node_modules\gulp-ssh\node_modules\ssh2\node_modules\ssh2-streams\lib\sftp.js:170:15)
    at SFTPStream.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:300:12)
    at writeOrBuffer (_stream_writable.js:286:5)
    at SFTPStream.Writable.write (_stream_writable.js:214:11)
    at Channel.ondata (_stream_readable.js:542:20)
    at emitOne (events.js:77:13)
    at Channel.emit (events.js:169:7)

goldenratio avatar Jul 06 '16 12:07 goldenratio

@goldenratio theres no support for this plugin i guess i just used rsync with child_process.exec in my gulpfile if you are on a mac or linux machine you can also do the same thing i am not sure about mac but on linux rsync comes pre-installed

ta3pks avatar Jul 07 '16 02:07 ta3pks

It seems the issue happens if I upload over 100 files or so.

goldenratio avatar Jul 07 '16 09:07 goldenratio

@goldenratio i tried to upload just a single binary about 30 mbytes

ta3pks avatar Jul 07 '16 09:07 ta3pks

could be related to this, https://github.com/mscdex/ssh2-streams/issues/32 @zensh has to update plugin's dependencies

goldenratio avatar Jul 07 '16 09:07 goldenratio

@goldenratio ssh2 should update it's dependencies~ https://github.com/mscdex/ssh2/blob/master/package.json#L8

zensh avatar Jul 07 '16 09:07 zensh

@zensh created issue ticket https://github.com/mscdex/ssh2/issues/448

goldenratio avatar Jul 07 '16 10:07 goldenratio

@zensh https://github.com/mscdex/ssh2-streams/issues/41#issuecomment-231402000

goldenratio avatar Jul 08 '16 16:07 goldenratio

Are there any updates regarding this? Seems like it's still not working with a large number of files.

marco-koenen avatar Jan 12 '21 17:01 marco-koenen

Are there any updates regarding this? Seems like it's still not working with a large number of files.

Same issue here. Any solutions or workarounds anyone?

WhereJuly avatar Mar 18 '21 08:03 WhereJuly

I had to keep using gulp-ssh as the most effective solution for my deploy as I would not like to switch from Windows to linux or to pollute my machine with WSL for just one project, neither could I use the normal CI/CD instruments (e.g. Github Actions) due to the project in part comprises a heavy legacy codebase not suited for deploying from SVN.

So I had to find a workaround. That took some fresh thinking.

Here is it all from my Gulp deploy task:

  • Zip the built in advance code on my local dev machine with gulp-zip;

  • Upload the ziped code to a server with pscps utility from PuTTY package being run as a Windows CLI command using Node child_process.spawn. Of course I had to construct the PSCP command that sounded like that: pscp -r -i z:path\to\my\key\file\server.ppk "..\built\code\folder\zipped-deploy-version.zip" [email protected]:/var/www/myproject/deploy/folder;

  • And then unzip it there with gulp-ssh exec executing somethng like cd /var/www/myproject/deploy/folder && unizip -o zipped-deploy-version.zip.

Hope that helps someone.

WhereJuly avatar Mar 29 '21 06:03 WhereJuly