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

out of the box error for command :Wandbox #10

Closed
niklasnolte opened this issue Jun 12, 2018 · 15 comments
Closed

out of the box error for command :Wandbox #10

niklasnolte opened this issue Jun 12, 2018 · 15 comments

Comments

@niklasnolte
Copy link

niklasnolte commented Jun 12, 2018

When running :Wandbox on the following code ( only open file in vim 8 ) right after I installed it with vundles PluginInstall, I get the error shown below.

Did I miss some installation instruction?

Arch Linux 4.16.5-1-ARCH
vim 8.1.22

#include <iostream>

int main () {
  std::cout << "hello world" << std::endl;
}
Error detected while processing function wandbox#run_sync_or_async[4]..wandbox#run[4]..wandbox#compile:
line   19:
E605: Exception not caught: Request has failed! Status 0: 
Error detected while processing function wandbox#run_sync_or_async:
line    4:
E171: Missing :endif
@rhysd
Copy link
Owner

rhysd commented Jun 14, 2018

I tried it on my machine (macOS 12.11) and I could not see the error.

2018-06-14 13 22 17

This plugin is for a web service. So the service might not work for you. Could you try again now and confirm this issue still occurs?

And if you write some configuration for wandbox-vim in your vimrc, please let me know it.

@forno
Copy link

forno commented Jun 27, 2018

Hi @rhysd

I have the same problem.
My error message is:

function wandbox#run_sync_or_async[4]..wandbox#run[4]..wandbox#compile の処理中にエラーが検出されました:
行   19:
E605: 例外が捕捉されませんでした: Request has failed! Status 0: 
function wandbox#run_sync_or_async の処理中にエラーが検出されました:
行    4:
E171: :endif がありません

I research this problem's precision with lxc.
The result says Vim8.0 or newer has this problem, maybe.

Here is my experiment result:

The common environment;
vim-package (I put wandbox-vim to .vim/pack/wandbox/start/)
commit# 71c97b1

  1. Fail: My main computer: Ubuntu 18.04 & Vim 8.1.0115
  2. Fail: Ubuntu 18.04 container: Ubuntu18.04 & Vim 8.0.1453
  3. Success: Ubuntu 16.04 container: Ubuntu 16.04 & Vim 7.4.1689 extra 8.0.0056

What do you think for this?

@niklasnolte
Copy link
Author

i can still confirm the error, no specialities in .vimrc

@forno
Copy link

forno commented Jun 27, 2018

Additional information.

I tryed to remove if ! response.success section on function! wandbox#compile in autoload/wandbox.vim.

I see correct movement.

## clang-head
  Hello world

It say that response.content has correct moving, But response.success and response.status are not working.
I see that vital.http are broken.

wandbox-vim's vital.vim may not support vim 8.x.

@bsamorodov
Copy link

I've got the same error using vim via Termux at Android.

@bsamorodov
Copy link

I'm not sure what's the actual bug is, but the following patch made wandbox act as expected.

diff --git a/autoload/wandbox.vim b/autoload/wandbox.vim
index daf97c3..a08052a 100644
--- a/autoload/wandbox.vim
+++ b/autoload/wandbox.vim
@@ -420,7 +420,7 @@ function! wandbox#compile(code, compiler, options, runtime_options, stdin)
                 \ 'method' : 'POST',
                 \ 'client' : (g:wandbox#disable_python_client ? ['curl', 'wget'] : ['python', 'curl', 'wget']),
                 \ })
-    if ! response.success
+    if response.success != 0
         throw "Request has failed! Status " . response.status . ': ' . response.statusText
     endif
     return s:JSON.decode(response.content)

@rhysd
Copy link
Owner

rhysd commented Jul 14, 2018

I'm sorry for catching the comments lately. It's very weird for me that modifying !response.success to response.success != 0 solve this issue since they mean the same in this context... But if really the modification fixes this issue, I'll add it to master.

rhysd added a commit that referenced this issue Jul 14, 2018
@rhysd
Copy link
Owner

rhysd commented Jul 14, 2018

@niklasnolte @forno @bsamorodov I added the modification at 700456e. Could you try?

@forno
Copy link

forno commented Jul 16, 2018

@rhysd
It fixes this problem in every environment.
Thank you!

@forno
Copy link

forno commented Jul 16, 2018

hmm...

I notice broken all others command. ex)WandboxOptionList
The fix makes degradation. Commands were working before the fix.

And this is an important point.
Web.HTTP's response.success means 1 is Success, 0 is Failed.
https://github.com/vim-jp/vital.vim/blob/master/doc/vital/Web/HTTP.txt#L163-L164

So, I think...
On old (or Vim 7.x), vital.vim's Web.HTTP undefine response.success on connection failed.
However, on new (or Vim 8.x), it defines response.success to 0 on connection failed.

Here say that if ! response.success means check to be defined.
It isn't equal if response.success != 0.

I don't know what happens.

  • :Wandbox command's response.success is 0.
  • :WandboxOptionList command's response.success is 1.

What different between them?
It may API problem, I think.

rhysd added a commit that referenced this issue Jul 16, 2018
@rbtnn
Copy link

rbtnn commented Mar 9, 2019

日本語で申し訳ないですが、同じ現状っぽいので報告しておきます。

私も:Wandboxを実行して以下のエラーになってしまいました。

Error detected while processing function wandbox#run_sync_or_async[4]..wandbox#run[4]..wandbox#compile:
line   20:
E605: Exception not caught: Request has failed! Status 0: 
Error detected while processing function wandbox#run_sync_or_async:
line    4:
E171: Missing :endif
Press ENTER or type command to continue

で、以下の部分にprintfデバッグを仕込んでみたら、HTTP 200なのにsuccessが0になるケースが存在するみたいです。

function! wandbox#compile(code, compiler, options, runtime_options, stdin)
    ...
    let response = s:HTTP.request({
                \ 'url' : 'https://wandbox.org/api/compile.json',
                \ 'data' : s:JSON.encode(data),
                \ 'headers' : {'Content-type' : 'application/json'},
                \ 'method' : 'POST',
                \ 'client' : (g:wandbox#disable_python_client ? ['curl', 'wget'] : ['python', 'curl', 'wget']),
                \ })
    echo response
    ...
endfunction
{'status': 0, 'success': 0, 'header': ['HTTP/2 200 ', 'server: nginx/1.10.3 (Ubuntu)', 'date: Sat, 09 Mar 2019 13:34:56 GMT', 'content-type: application/json', 'access-control-allow-origin: *', 'x-powered
-by: CppCMS/1.0.5', 'strict-transport-security: max-age=31536000; includeSubdomains'], 'statusText': '', 'content': '{
        "compiler_error" :      "\u001B[1mprog.c:7:21: \u001B[0m\u001B[0;1;35mwarning: \u001B[0m\u001B[1mformat specifies type ''long'' but the argument has type ''int'' [-Wformat]\u001B[0m\n    printf(\"
%ld\\n\", 1);\n\u001B[0;1;32m            ~~~     ^\n\u001B[0m\u001B[0;32m            %d\n\u001B[0m1 warning generated.\n",
        "compiler_message" :    "\u001B[1mprog.c:7:21: \u001B[0m\u001B[0;1;35mwarning: \u001B[0m\u001B[1mformat specifies type ''long'' but the argument has type ''int'' [-Wformat]\u001B[0m\n    printf(\"
%ld\\n\", 1);\n\u001B[0;1;32m            ~~~     ^\n\u001B[0m\u001B[0;32m            %d\n\u001B[0m1 warning generated.\n",
        "program_message" :     "1\n",
        "program_output" :      "1\n",
        "status" :      "0"
}
'}

@rbtnn
Copy link

rbtnn commented Mar 9, 2019

vital.Web.HTTPがHTTP/2に対応してませんね

@rhysd
Copy link
Owner

rhysd commented Mar 9, 2019

@rbtnn 報告ありがとうございます.うーん私の手元では普通に最新で動いてるのですよね…(HTTP/1.1) HTTP/2 でないと動かないということは無いと思うのですが…

@rhysd rhysd closed this as completed in ea4d294 Mar 9, 2019
@rhysd
Copy link
Owner

rhysd commented Mar 9, 2019

@rbtnn なにはともあれ, ea4d294 で HTTP/2 のヘッダをパースできるようにしてみました.もしまだ動かないようなら教えていただけると助かります.

@rbtnn
Copy link

rbtnn commented Mar 9, 2019

@rhysd ea4d294 で動くことを確認できました。ありがとうございます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants