发出http请求时出现延迟作业错误

时间:2011-08-25 01:53:41

标签: ruby-on-rails delayed-job

当我处理具有延迟作业的作业时,我遇到了utils.rb:333中的错误,该作业在同步运行时运行良好。基本上我正在做的是在我的代码中发出get请求,当我这样做时,我遇到了错误。这是遇到错误的代码行:

self.fb_friends = (JSON.parse self.fb_token.get('me/friends')).first[1] unless self.fb_friends

self是一个ruby类,self.fb_token在这里创建

OAuth2::AccessToken.new client, fb_token_string

其中client是调用OauthHelper :: client的结果,fb_token_string是来自facebook的标记字符串

这是我的堆栈跟踪:

{You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.delete
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.3/lib/rack/utils.rb:333:in `delete'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.3/lib/rack/utils.rb:326:in `[]='\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/utils.rb:28:in `[]='\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/utils.rb:85:in `block in merge_headers'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/utils.rb:84:in `each'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/utils.rb:84:in `merge_headers'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/request.rb:69:in `to_env_hash'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/request.rb:87:in `run'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/request.rb:28:in `run'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/faraday-0.6.1/lib/faraday/connection.rb:170:in `run_request'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/oauth2-0.4.1/lib/oauth2/client.rb:59:in `request'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/oauth2-0.4.1/lib/oauth2/access_token.rb:34:in `request'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/oauth2-0.4.1/lib/oauth2/access_token.rb:38:in `get'\n
/Users/myuseraccount/Sites/tutorcloud/app/models/facebook_session.rb:69:in `get_fb_likes'\n
/Users/myuseraccount/Sites/tutorcloud/app/models/facebook_session.rb:305:in `save_to_user_info'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/performable_method.rb:20:in `perform'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:87:in `invoke_job'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block (2 levels) in run'\n
/Users/myuseraccount/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block in run'\n
/Users/myuseraccount/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:119:in `run'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:177:in `reserve_and_run_one_job'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:104:in `block in work_off'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `times'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `work_off'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:78:in `block (2 levels) in start'\n
/Users/myuseraccount/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:77:in `block in start'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `loop'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `start'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:104:in `run'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:83:in `block in run_process'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/application.rb:249:in `call'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/application.rb:249:in `block in start_proc'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/daemonize.rb:197:in `call'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/daemonize.rb:197:in `call_as_daemon'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/application.rb:253:in `start_proc'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/application.rb:293:in `start'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/controller.rb:70:in `run'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons.rb:195:in `block in run_proc'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/cmdline.rb:109:in `call'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons/cmdline.rb:109:in `catch_exceptions'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.4/lib/daemons.rb:194:in `run_proc'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:81:in `run_process'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:75:in `block in daemonize'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:in `times'\n
/Users/myuseraccount/.rvm/gems/ruby-1.9.2-p0/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:in `daemonize'\n
script/delayed_job:5:in `<main>'

1 个答案:

答案 0 :(得分:0)

我遇到了同样的错误

尝试将Oauth2更新为0.5.0 当我将Omniauth更新为0.3.0.rc2并将Oauth更新为0.5.0时 - 问题已解决