ensure closed-over $resource variable is weak