Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

SystemStackError, stack level too deep #349

Closed
sonereker opened this Issue · 17 comments
@sonereker

With latest RVM, Ruby 1.9.2, delayed_job_active_record (0.3.2), Rails 3.2.0, pow (or webrick/thin);

I get "stack level too deep" error with notifier.

Notifier.delay(queue: "invitation").invitation(email, name)

Any suggestions?

@pascalj

I had the same error (also with ActionMailer, other jobs seemed to work). I experimented a bit and, although I don't know exactly why, it had to do with a require 'yaml' that was leftover in my config/boot.rb. Removing the line fixed the problem for me.

@mendable

+1

a config/initializer setup with content below breaks some (all?) .delay. method calls.

require 'yaml'
YAML::ENGINE.yamler = 'psych'

Error received is this (no further stack trace, that's it)

  SystemStackError (stack level too deep):
    actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:70

Rails 3.2.1, Delayed Job 2.1.4 (last working one for me with Rails 3.2.1 at this time).

@asavartsov

I had SystemStackError on mailers with rails 3.2.1, ruby 1.9.2p290 and delayed_job+delayed_job_mongoid. Upgrading to ruby 1.9.3p150 solved problem for me.

@shyam-habarakada

I'm getting the same error, but it doesn't seem to fail if I trie the identical steps in a rails console (on the same server). And I canot reproduce the error at all on a development OXS server with action mailer deliveries set to the same as the ubuntu staging server.

My configuration is RVM + Rails 3.2.0 + Passenger + Apache

The failing code looks like

@user = User.new()
# set various properties of the user

if try_save(@user)
    SomeMailer.delay.welcome_new_user(@user)
end

The error is

SystemStackError (stack level too deep):
  activesupport (3.2.0) lib/active_support/callbacks.rb:409

Here's my RVM configuration

ruby-1.9.2-p290:

  system:
    uname:       "Linux ve.77n7w8rt.vesrv.com 2.6.18-028stab099.3 #1 SMP Wed Mar 7 15:20:22 MSK 2012 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]"
    updated:      "2 months 7 days 19 hours 35 minutes 29 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p290"
    date:         "2011-07-09"
    platform:     "x86_64-linux"
    patchlevel:   "2011-07-09 revision 32553"
    full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]"

and relevant gem versions

  * rails (3.2.0)
  * delayed_job (3.0.1)
  * delayed_job_active_record (0.3.2)
@shyam-habarakada

After some digging around I noticed that the error is raised from

/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/nodes/node.rb:17

and the callstack shows ..

/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.1/lib/delayed/message_sending.rb:13:in `method_missing'
... # application code that invokes SomeMailer.delay.mail_method(with_params)
...

psych is indeed what is causing this. I'm still unclear on why this is happening only in one of my staging environments.

@mendable how did you resolve your issue? Did you actually find and remove a call to require 'yaml' as @pascalj suggested (above) or did you upgrade ruby to 1.9.3? Something else? Thanks in advance.

UPDATE

After upgrading to 1.9.3-p125 and rails 3.2.3, the problem no longer reproduces for me.

@neerajdotname

I am getting this error.

Upgraded to 1.9.3-p125 and rails 3.2.3 and I still have this error.

@pftg

Quick fix: just add encode_with with empty method body for Mailer, that psych will know how to serialize Mailer class.

class Mailer
...
  def encode_with coder
  end
...
end

Problem lines which hide this bug by 'stack too deep' in https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/yaml_ext.rb#L5
so line with:

require File.expand_path('../psych_ext', __FILE__)

is never calls
but it's needed when to_yaml use psych engine as default.

UPD.: In my dependency was systemu, which reverting YAML engine to psych after DelayedJobs required with 'syck' engine, so yaml_ext works correctly, just my bad with my dependencies:

carrierwave_direct => uuid => macaddr => systemu.
@kaeus

I've been getting something similar, however its just with DelayedJob running without any jobs being started. I used DJ for custom jobs, but that is it. I did add a mailer around when this started, but I tried to remove the related files. I'm not sure if that was exactly what caused this to start or not for me. I had Daemon Spawn working nicely, then for some reason this started to happen. I'm trying to recall what gems I updated.

Using the following versions:
Ruby (1.9.3-p125)
Rails (3.2.3)
delayed_job (3.0.2)
delayed_job_active_record (0.3.2)
alexvollmer-daemon-spawn (0.2.0)

I was having issues with daemons gem (1.0.10 basically kept spawning new workers and was unable to kill off old ones, 1.1.0+ just constantly threw broken pipe errors that I couldn't resolve)

The only thing I can see in my delayed_job.log is

 script/delayed_job:18: stack level too deep (SystemStackError)
@pupeno

I had this error with the following two lines in boot.rb:

require "yaml"
YAML::ENGINE.yamler = "syck"
@pftg

@pupeno please review my comment above. I have already described why this happen.

@pftg

@kaeus you see

script/delayed_job:18: stack level too deep (SystemStackError)

because you tried to serialize Mailer object without encode_with method.

@bulanlily

We met the same problem.That is because we have a enqueue method in our delayed job object.
After do into the source code ,we found this would cause an cycle.so,rename it!

@whitslar

@bulanilly You + Google just saved me many many hours..

@jamsi

I had this issue recently when I rebuilt 1.9.2 with ssl. Upgrading to 1.9.3 worked, but does anybody know why?

@dgaeta

+1 @pftg

Your answer worked for me. Thanks!!

@fro

Upgrading to 1.9.3 worked for me either.

@pawel2105 pawel2105 referenced this issue in collectiveidea/delayed_job_mongoid
Open

Stack level too deep #21

@pawel2105

On ruby-1.9.3-p392 and Rails 3.0.20 and delayed_job 3.0.5 the solution was @pftg's suggestion.

:+1: :dancer:

@albus522 albus522 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.