iriscouch / browserid_couchdb

Mozilla BrowserID support plugin for CouchDB
Apache License 2.0
57 stars 9 forks source link

500 error accessing _browserid/include.js #7

Closed timbertson closed 12 years ago

timbertson commented 12 years ago

Using a fresh couchdb-build on ubuntu 11.10 with only this plugin enabled (and enabled in config), I can't get http://localhost:5985/_browserid/include.js

When I try, the console gives me:

[error] [<0.2585.0>] Uncaught error in HTTP request: {error,undef}
[info] [<0.2585.0>] Stacktrace: [{couch_httpd_browserid,handle_id_req,
                                  [{httpd,
                                    {mochiweb_request,#Port<0.2190>,'GET',
                                     "/_browserid/include.js",
                                     {1,1},
                                     {3,
                                      {"user-agent",
                                       {'User-Agent',
                                        "curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3"},
                                       {"host",
                                        {'Host',"localhost:5985"},
                                        {"accept",{'Accept',"*/*"},nil,nil},
                                        nil},
                                       nil}}},
                                    "127.0.0.1",'GET',
                                    [<<"_browserid">>,<<"include.js">>],
                                    [<<"_browserid">>,<<"include.js">>],
                                    {dict,5,16,16,8,80,48,
                                     {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                      [],[],[]},
                                     {{[[<<"_design">>|
                                         #Fun<couch_httpd.8.127141751>]],
                                       [],
                                       [[<<"_view_cleanup">>|
                                         #Fun<couch_httpd.8.127141751>]],
                                       [],[],[],[],[],
                                       [[<<"_compact">>|
                                         #Fun<couch_httpd.8.127141751>]],
                                       [],[],
                                       [[<<"_temp_view">>|
                                         #Fun<couch_httpd.8.127141751>]],
                                       [[<<"_changes">>|
                                         #Fun<couch_httpd.8.127141751>]],
                                       [],[],[]}}},
                                    {user_ctx,null,
                                     [<<"_admin">>],
                                     <<"{couch_httpd_auth, default_authentication_handler}">>},
                                    undefined,
                                    {dict,6,16,16,8,80,48,
                                     {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                      [],[],[]},
                                     {{[],
                                       [[<<"_show">>|
                                         #Fun<couch_httpd.10.127141751>]],
                                       [[<<"_info">>|
                                         #Fun<couch_httpd.10.127141751>],
                                        [<<"_list">>|
                                         #Fun<couch_httpd.10.127141751>]],
                                       [[<<"_update">>|
                                         #Fun<couch_httpd.10.127141751>]],
                                       [],[],[],[],[],
                                       [[<<"_rewrite">>|
                                         #Fun<couch_httpd.10.127141751>]],
                                       [],[],[],
                                       [[<<"_view">>|
                                         #Fun<couch_httpd.10.127141751>]],
                                       [],[]}}},
                                    undefined,#Fun<couch_httpd.6.127141751>,
                                    {dict,14,16,16,8,80,48,
                                     {[],[],[],[],[],[],[],[],[],[],[],[],[],
                                      [],[],[]},
                                     {{[[<<"_restart">>|
                                         #Fun<couch_httpd.6.127141751>],
                                        [<<"_replicate">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [[<<"_active_tasks">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [],[],
                                       [[<<"_utils">>|
                                         #Fun<couch_httpd.5.127141751>],
                                        [<<"/">>|
                                         #Fun<couch_httpd.5.127141751>],
                                        [<<"_config">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [[<<"_log">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [[<<"_browserid">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [],
                                       [[<<"_all_dbs">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [],
                                       [[<<"_stats">>|
                                         #Fun<couch_httpd.6.127141751>],
                                        [<<"favicon.ico">>|
                                         #Fun<couch_httpd.5.127141751>]],
                                       [[<<"_session">>|
                                         #Fun<couch_httpd.6.127141751>],
                                        [<<"_uuids">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       [],[],
                                       [[<<"_oauth">>|
                                         #Fun<couch_httpd.6.127141751>]],
                                       []}}}}],
                                  []},
                                 {couch_httpd,handle_request_int,5,
                                  [{file,
                                    "/home/tim/dev/web/couchdb/build-couchdb/dependencies/couchdb/src/couchdb/couch_httpd.erl"},
                                   {line,262}]},
                                 {mochiweb_http,headers,5,
                                  [{file,
                                    "/home/tim/dev/web/couchdb/build-couchdb/dependencies/couchdb/src/mochiweb/mochiweb_http.erl"},
                                   {line,126}]},
                                 {proc_lib,init_p_do_apply,3,
                                  [{file,"proc_lib.erl"},{line,227}]}]
[info] [<0.2585.0>] 127.0.0.1 - - 'GET' /_browserid/include.js 500

I've not dealt with erlang stack traces before, but I'm not sure if there's much there to go on...

timbertson commented 12 years ago

After getting the .js sources manually and trying it out, I get a 500 when I try to POST my assertion as well. So it's not just a matter of serving up files, the plugin in general seems to be responding with 500 errors. Which is unsurprising, given that serving files is probably not the hard part ;)

jhs commented 12 years ago

I believe this is an issue with activating the plugin. Erlang cannot find couch_httpd_browserid.beam so it can't run the handler code for the HTTP requests to /_browserid.

Try something like

export ERL_ZFLAGS="-pz /path/to/couchdb/lib/couchdb/plugins/browserid_couchdb/ebin"

before you run couch. How'd it go?

timbertson commented 12 years ago

That works perfectly, thanks. Was it an instruction I missed, or should this have been set up by build-couchdb? I am just running "~/dev/web/couchdb/build-couchdb/build/bin/couchdb" directly, not cding anywhere in particular or sourcing env.sh. I thought that was fine according to the instructions, but I may have missed something.

jhs commented 12 years ago

Unfortunately, this is getting into intermediate/advanced Erlang and CouchDB development. (Well, it's no more advanced than $RUBYPATH, or $PYTHON_PATH, but those languages are more widely known.)

Some planning is underway about making a proper plugin framework for projects like this, but until then it's a bit of bubble gum and duct tape.

interactiveblueprints commented 12 years ago

Could this 'workaround' be added tot the documentation? I've spend a long time searching for this solution.

pfrazee commented 11 years ago

:+1: for getting this info out there; just spent 30 minutes on it

dmrq70 commented 11 years ago

+1 for getting this in the README. Not even google is finding this discussion.